From b3673d1fdc206936a58d37b5c2bcb1452be283db Mon Sep 17 00:00:00 2001 From: Sampsa Penna Date: Thu, 16 Mar 2023 14:44:09 +0200 Subject: [PATCH] fix libupload and websocket with tls proxy --- devproxy/nginx.conf | 20 ++------------------ swift_browser_ui_frontend/vite.config.js | 11 ++++++----- 2 files changed, 8 insertions(+), 23 deletions(-) diff --git a/devproxy/nginx.conf b/devproxy/nginx.conf index df94383bb..b12106fb4 100644 --- a/devproxy/nginx.conf +++ b/devproxy/nginx.conf @@ -93,27 +93,11 @@ http { proxy_pass http://app_server_front/ws; } - location /libupload.js { - proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; - proxy_set_header X-Forwarded-Proto $scheme; - proxy_set_header Host $http_host; - proxy_redirect off; - proxy_buffering off; - proxy_pass http://app_server_front/static/libupload.js; - } - - location /libupload.wasm { - proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; - proxy_set_header X-Forwarded-Proto $scheme; - proxy_set_header Host $http_host; - proxy_redirect off; - proxy_buffering off; - proxy_pass http://app_server_front/static/libupload.wasm; - } - location / { proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; proxy_set_header X-Forwarded-Proto $scheme; + proxy_set_header Upgrade $http_upgrade; + proxy_set_header Connection "Upgrade"; proxy_set_header Host $http_host; proxy_redirect off; proxy_buffering off; diff --git a/swift_browser_ui_frontend/vite.config.js b/swift_browser_ui_frontend/vite.config.js index 7e3c7892f..543da6822 100644 --- a/swift_browser_ui_frontend/vite.config.js +++ b/swift_browser_ui_frontend/vite.config.js @@ -28,6 +28,8 @@ const proxyTo = { const oidcEnabled = process.env.OIDC_ENABLED === "True"; const root = path.resolve(__dirname, "src"); +const publicDir = path.resolve(__dirname, "public"); + let pages = { "index": path.resolve(root, "index.html"), "select": path.resolve(root, "select.html"), @@ -48,7 +50,6 @@ let proxy = { "/static/assets": proxyTo, "/api": proxyTo, "/discover": proxyTo, - "/libupload": proxyTo, "/login/oidc": proxyTo, "/login/oidc_front": proxyTo, "/login/oidc-redirect": proxyTo, @@ -61,12 +62,10 @@ let proxy = { "/sign": proxyTo, "/replicate": proxyTo, "/token": proxyTo, - "/ws": { - target: `ws${process.env.SWIFT_UI_SECURE_WEBSOCKET}://${process.env.SWIFT_UI_TLS_HOST}:${process.env.SWIFT_UI_TLS_PORT}/ws`, - ws: true, - }, }; +let origin = `http${process.env.SWIFT_UI_SECURE_WEBSOCKET}://${process.env.SWIFT_UI_TLS_HOST}:${process.env.SWIFT_UI_TLS_PORT}`; + // Vite doesn't work "out-of-the-box" with multiple SPAs // This middleware loads existing html pages and // forwards all routes starting with "/browse" to "browse.html" @@ -131,6 +130,7 @@ export default defineConfig(({ command, mode }) => { return { root, base, + publicDir, appType: "mpa", // set the dev server as a multi-page app plugins: [ vue(), @@ -153,6 +153,7 @@ export default defineConfig(({ command, mode }) => { https, strictPort: true, proxy, + origin, }, resolve: { alias: {