* supports overriding the replayweb.page version without having to be rebuild frontend image: - ensures 'rwp_base_url' from helm chart is passed to nginx - ensures both ui.js and sw.js are loaded based on nginx environment variable, not hard-coded - ui.js loaded via redirect from new /replay/ui.js path - pin RWP to known working release in default values.yaml - remove RWP_BASE_URL from Dockerfile, no longer needed, set via chart env var - set default RWP_BASE_URL for devserver to use CDN - set RWP version to 1.8.11
		
			
				
	
	
		
			46 lines
		
	
	
		
			1.2 KiB
		
	
	
	
		
			JavaScript
		
	
	
	
	
	
			
		
		
	
	
			46 lines
		
	
	
		
			1.2 KiB
		
	
	
	
		
			JavaScript
		
	
	
	
	
	
| const path = require("path");
 | |
| require(path.resolve(process.cwd(), "./webpack.config.js"));
 | |
| 
 | |
| // for testing: for prod, using the version specified in Helm values.yaml
 | |
| const RWP_BASE_URL =
 | |
|   process.env.RWP_BASE_URL || "https://cdn.jsdelivr.net/npm/replaywebpage/";
 | |
| 
 | |
| if (!process.env.API_BASE_URL) {
 | |
|   throw new Error(
 | |
|     "To run a dev frontend server, please set the API_BASE_URL pointing to your backend api server in '.env.local'"
 | |
|   );
 | |
| }
 | |
| 
 | |
| const devBackendUrl = new URL(process.env.API_BASE_URL);
 | |
| 
 | |
| module.exports = {
 | |
|   proxy: {
 | |
|     "/api": {
 | |
|       target: devBackendUrl.href,
 | |
|       headers: {
 | |
|         Host: devBackendUrl.host,
 | |
|       },
 | |
|       ws: true,
 | |
|     },
 | |
| 
 | |
|     "/data": {
 | |
|       target: devBackendUrl.href,
 | |
|       headers: {
 | |
|         Host: devBackendUrl.host,
 | |
|       },
 | |
|     },
 | |
|   },
 | |
|   // Serve replay service worker file
 | |
|   onBeforeSetupMiddleware: (server) => {
 | |
|     server.app.get("/replay/sw.js", (req, res) => {
 | |
|       res.set("Content-Type", "application/javascript");
 | |
|       res.send(`importScripts("${RWP_BASE_URL}sw.js")`);
 | |
|     });
 | |
| 
 | |
|     server.app.get("/replay/ui.js", (req, res) => {
 | |
|       res.set("Content-Type", "application/javascript");
 | |
|       res.redirect(307, RWP_BASE_URL + "ui.js");
 | |
|     });
 | |
|   },
 | |
| };
 |