Ok the auto response helped me stop the server, which is good, but I was wrong about the cause of the problems.
On closer inspection, when Vite has built assets, pages render correctly. For example the default Auth scaffolding login page references assets like so when built:
<link rel="preload" as="style" href="https://laravelvite.ddev.site/build/assets/app-fc1fe159.css">
<link rel="modulepreload" href="https://laravelvite.ddev.site/build/assets/app-e7c8c463.js">
<link rel="stylesheet" href="https://laravelvite.ddev.site/build/assets/app-fc1fe159.css">
<script type="module" src="https://laravelvite.ddev.site/build/assets/app-e7c8c463.js"></script>
Note the paths are correct, the full DDEV url is used.
However when it's in dev/watching, here's the output:
<script type="module" src="http://127.0.0.1:5173/@vite/client"></script>
<link rel="stylesheet" href="http://127.0.0.1:5173/resources/css/app.css">
<script type="module" src="http://127.0.0.1:5173/resources/js/app.js"></script>
The assets are served from an IP and port that must be internal to the container, but as I'm viewing the site on https://laravelvite.ddev.site/login I get CORS errors and other nags:
- Cross-Origin Request Blocked: The Same Origin Policy disallows reading the remote resource at http://127.0.0.1:5173/@vite/client. (Reason: CORS request did not succeed). Status code: (null).
- Module source URI is not allowed in this document: “http://127.0.0.1:5173/@vite/client”.
- Cross-Origin Request Blocked: The Same Origin Policy disallows reading the remote resource at http://127.0.0.1:5173/resources/js/app.js. (Reason: CORS request did not succeed). Status code: (null).
- Module source URI is not allowed in this document: “http://127.0.0.1:5173/resources/js/app.js”.
- Loading module from “http://127.0.0.1:5173/@vite/client” was blocked because of a disallowed MIME type (“text/html”).
- Loading module from “http://127.0.0.1:5173/resources/js/app.js” was blocked because of a disallowed MIME type (“text/html”).
Does anyone know how I can get Vite to do relative pathing, or hardcode my URL into the config. Or maybe I need to approach this completely differently. As long as I end up with a containerised L10 install with Vite working, I'm open to suggestions 😅 - Ideally something that still allows me to use DDEv on other projects at the same time.