Vite (React) returns blank page behind Coder code-server proxy (absolute paths / MIME error) #7603
Unanswered
thibault-chausson
asked this question in
Q&A
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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