From fcbb24e8598300e083e38bd7df4131325ca8ea22 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 --- vite.config.js | 15 +++++++++++++++ 1 file changed, 15 insertions(+) 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,