From 64e2ad6d711bd58fb75567aef5a3a86f154f768a Mon Sep 17 00:00:00 2001 From: Saman Ehsan Date: Mon, 21 Aug 2023 15:04:47 -0400 Subject: [PATCH] Fix e2e test wait-on local server Work around wait-on 404 error Originally from: https://github.com/vitejs/vite/issues/9520#issuecomment-1660050942 --- .github/workflows/test-e2e.yml | 2 +- vite.config.js | 15 +++++++++++++++ 2 files changed, 16 insertions(+), 1 deletion(-) diff --git a/.github/workflows/test-e2e.yml b/.github/workflows/test-e2e.yml index 6c3f0e3c7..e368a2b6f 100644 --- a/.github/workflows/test-e2e.yml +++ b/.github/workflows/test-e2e.yml @@ -61,7 +61,7 @@ jobs: env: DISABLE_ESLINT_PLUGIN: true run: | - npm start & npx wait-on http://localhost:3000 + npm start & npx wait-on http://localhost:3000 --verbose # Build the Docker image - name: Build run: | diff --git a/vite.config.js b/vite.config.js index a743cec3a..b3c09cbd5 100644 --- a/vite.config.js +++ b/vite.config.js @@ -10,6 +10,20 @@ const bigQueryApi = 'https://bigquery.googleapis.com'; const googleSheetsApi = 'https://sheets.googleapis.com'; const driveApi = 'https://www.googleapis.com'; +function fixAcceptHeader404() { + return { + name: 'fix-accept-header-404', // issue with vite dev server: https://github.com/vitejs/vite/issues/9520 + configureServer(server) { + server.middlewares.use((req, _res, next) => { + if (req.headers.accept == 'application/json, text/plain, */*') { + req.headers.accept = '*/*'; + } + next(); + }); + }, + }; +} + dns.setDefaultResultOrder('verbatim'); export default defineConfig({ @@ -29,6 +43,7 @@ export default defineConfig({ svgr(), tsconfigPaths(), eslint(), + fixAcceptHeader404(), ], server: { port: 3000,