| 
									
										
										
										
											2021-08-17 13:00:46 -07:00
										 |  |  | const fs = require('fs'); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | let PROXY_CONFIG; | 
					
						
							|  |  |  | let configContent; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | const CONFIG_FILE_NAME = 'mempool-frontend-config.json'; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | try { | 
					
						
							|  |  |  |     const rawConfig = fs.readFileSync(CONFIG_FILE_NAME); | 
					
						
							|  |  |  |     configContent = JSON.parse(rawConfig); | 
					
						
							|  |  |  |     console.log(`${CONFIG_FILE_NAME} file found, using provided config`); | 
					
						
							|  |  |  | } catch (e) { | 
					
						
							|  |  |  |     console.log(e); | 
					
						
							|  |  |  |     if (e.code !== 'ENOENT') { | 
					
						
							|  |  |  |       throw new Error(e); | 
					
						
							|  |  |  |   } else { | 
					
						
							|  |  |  |       console.log(`${CONFIG_FILE_NAME} file not found, using default config`); | 
					
						
							|  |  |  |   } | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | PROXY_CONFIG = [ | 
					
						
							|  |  |  |     { | 
					
						
							| 
									
										
										
										
											2022-02-06 15:10:35 -08:00
										 |  |  |         context: ['*', | 
					
						
							|  |  |  |         '/api/**', '!/api/v1/ws', | 
					
						
							| 
									
										
										
										
											2021-08-17 13:00:46 -07:00
										 |  |  |         '!/bisq', '!/bisq/**', '!/bisq/', | 
					
						
							|  |  |  |         '!/liquid', '!/liquid/**', '!/liquid/', | 
					
						
							| 
									
										
										
										
											2021-12-27 22:54:45 +04:00
										 |  |  |         '!/liquidtestnet', '!/liquidtestnet/**', '!/liquidtestnet/', | 
					
						
							| 
									
										
										
										
											2021-08-17 13:00:46 -07:00
										 |  |  |         '/testnet/api/**', '/signet/api/**' | 
					
						
							|  |  |  |         ], | 
					
						
							|  |  |  |         target: "https://mempool.space", | 
					
						
							|  |  |  |         ws: true, | 
					
						
							|  |  |  |         secure: false, | 
					
						
							|  |  |  |         changeOrigin: true | 
					
						
							|  |  |  |     }, | 
					
						
							|  |  |  |     { | 
					
						
							|  |  |  |         context: ['/api/v1/ws'], | 
					
						
							|  |  |  |         target: "https://mempool.space", | 
					
						
							|  |  |  |         ws: true, | 
					
						
							|  |  |  |         secure: false, | 
					
						
							|  |  |  |         changeOrigin: true, | 
					
						
							|  |  |  |     }, | 
					
						
							|  |  |  |     { | 
					
						
							|  |  |  |         context: ['/api/bisq**', '/bisq/api/**'], | 
					
						
							|  |  |  |         target: "https://bisq.markets", | 
					
						
							|  |  |  |         pathRewrite: { | 
					
						
							|  |  |  |             "^/api/bisq/": "/bisq/api" | 
					
						
							|  |  |  |         }, | 
					
						
							|  |  |  |         ws: true, | 
					
						
							|  |  |  |         secure: false, | 
					
						
							|  |  |  |         changeOrigin: true | 
					
						
							|  |  |  |     }, | 
					
						
							|  |  |  |     { | 
					
						
							|  |  |  |         context: ['/api/liquid**', '/liquid/api/**'], | 
					
						
							|  |  |  |         target: "https://liquid.network", | 
					
						
							|  |  |  |         pathRewrite: { | 
					
						
							|  |  |  |             "^/api/liquid/": "/liquid/api" | 
					
						
							|  |  |  |         }, | 
					
						
							|  |  |  |         ws: true, | 
					
						
							|  |  |  |         secure: false, | 
					
						
							|  |  |  |         changeOrigin: true | 
					
						
							| 
									
										
										
										
											2021-12-27 22:54:45 +04:00
										 |  |  |     }, | 
					
						
							|  |  |  |     { | 
					
						
							|  |  |  |         context: ['/api/liquidtestnet**', '/liquidtestnet/api/**'], | 
					
						
							| 
									
										
										
										
											2022-01-20 11:27:50 -08:00
										 |  |  |         target: "https://liquid.network", | 
					
						
							| 
									
										
										
										
											2021-12-27 22:54:45 +04:00
										 |  |  |         ws: true, | 
					
						
							|  |  |  |         secure: false, | 
					
						
							|  |  |  |         changeOrigin: true | 
					
						
							| 
									
										
										
										
											2022-02-06 15:10:35 -08:00
										 |  |  |     }, | 
					
						
							|  |  |  |     { | 
					
						
							|  |  |  |       context: ['/resources/mining-pools/**'], | 
					
						
							|  |  |  |       target: "https://mempool.space", | 
					
						
							|  |  |  |       secure: false, | 
					
						
							|  |  |  |       changeOrigin: true | 
					
						
							|  |  |  |   } | 
					
						
							| 
									
										
										
										
											2021-08-17 13:00:46 -07:00
										 |  |  | ]; | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2021-10-22 11:54:28 -07:00
										 |  |  | if (configContent && configContent.BASE_MODULE == "liquid") { | 
					
						
							|  |  |  |     PROXY_CONFIG.push({ | 
					
						
							| 
									
										
										
										
											2022-12-16 18:01:04 +01:00
										 |  |  |         context: [ | 
					
						
							| 
									
										
										
										
											2022-01-20 11:27:50 -08:00
										 |  |  |             '/resources/assets.json', '/resources/assets.minimal.json', | 
					
						
							|  |  |  |             '/resources/assets-testnet.json', '/resources/assets-testnet.minimal.json'], | 
					
						
							| 
									
										
										
										
											2021-10-22 11:54:28 -07:00
										 |  |  |         target: "https://liquid.network", | 
					
						
							|  |  |  |         secure: false, | 
					
						
							|  |  |  |         changeOrigin: true, | 
					
						
							|  |  |  |     }); | 
					
						
							|  |  |  | } else { | 
					
						
							| 
									
										
										
										
											2021-10-27 20:32:42 -07:00
										 |  |  |     PROXY_CONFIG.push({ | 
					
						
							| 
									
										
										
										
											2022-12-16 18:01:04 +01:00
										 |  |  |         context: ['/resources/assets.json', '/resources/assets.minimal.json', '/resources/worldmap.json'], | 
					
						
							| 
									
										
										
										
											2021-10-22 11:54:28 -07:00
										 |  |  |         target: "https://mempool.space", | 
					
						
							|  |  |  |         secure: false, | 
					
						
							|  |  |  |         changeOrigin: true, | 
					
						
							|  |  |  |     }); | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2021-08-17 13:00:46 -07:00
										 |  |  | module.exports = PROXY_CONFIG; |