Vite (React) returns blank page behind Coder code-server proxy (absolute paths / MIME error) #7603
Replies: 1 comment
-
|
Ah yeah I think Vite is one of those applications that needs to see the full original path and cannot work relatively, at least based on what I have seen (I have not used it myself). For code-server you can use the non-rewriting I think the only solution might be to use subdomain-based apps instead of path-based apps. Or if you could forward the port in some other way, like through the I wonder if maybe Vite could be told to use a relative base? |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
-
Hello,
I’m reaching out because I’m facing an issue with Coder’s proxy when developing with Vite (React).
When I run
npm run dev, I get a blank page becausemain.jsxcannot be found, or I get a 404 error, depending on thevite.configconfiguration.Analysis
The actual URL is:
https://mondomanie.com/@user/test.main/apps/code-server/proxy/5173/The Vite server listens on
localhost:5173inside the workspace (when I runnpm run dev).The browser does not access
localhost:5173directly, but goes through the built-in code-server proxy.When the browser requests
/@vite/clientor/src/main.jsxthrough the proxy, Vite does not recognize this path and returnsindex.html, resulting in atext/htmlMIME error in the console.Even with a correct
allowedHosts, HMR disabled, andbaseconfigured as/@user/test.main/apps/code-server/proxy/5173/,Vite does not understand that proxy paths should map to
/.Consequences
<script type="module" src="/src/main.jsx">using absolute paths (/src/...)./src/...does not match the real URL, so the browser receives the proxy HTML page, hence thetext/htmlMIME error./, but the proxy adds a prefix (/@user/.../proxy/5173).Vite configuration
My browser redirects me to /proxy/5173/@user/test.main/apps/code-server/proxy/5173
Issue
I get this error when I click on the forwarded ports notification in code-server.

Do you have any ideas on how to fix this issue?
Thank you in advance.
Best regards,
Beta Was this translation helpful? Give feedback.
All reactions