Vite proxy is fetching clientside files

Viewed 459

I'm trying to migrate my react project from webpack to vite and I'm facing this issue with proxies:

I've configured my proxy like so:

      port: 8000,
      proxy: {
        '/api': {
          target: 'http://localhost:8080',
          changeOrigin: true,
        },
        '/graphql': {
          target: 'http://localhost:8080',
          changeOrigin: true,
        },
      },
    },

But if I use it like that, then vite starts requesting localhost:8080/api for clientside files like localhost:8080/api/index.ts which throws a MIME type error.

What’s the cause for this behavior and how can I fix it? The http-proxy documentation offers no details(which is what Vite uses)

0 Answers
Related