Nov 13, 2023
0
Level 5
Lando to Sail creates CORS errors
I'm trying to convert our app to use Sail instead of Lando on WSL.
- I've installed Sail and published its Docker files so that I can add opentelemetry to it. No problem there.
- I updated the
docker-composer.ymlfile to give that service a new name. - I've run
sail build --no-cache - I've updated the
<php>section ofphpunit.xmlto go back to<envs rather than<servers and setDB_CONNECTIONtopgsql. - I've updated
.envsoAPP_URLishttp://localhost.
Running sail npm run dev seems to run fine. However, no matter what I do, I get CORS errors when attempting to visit the page in a browser.
Cross-Origin Request Blocked: The Same Origin Policy disallows reading the remote resource at http://localhost:3009/@vite/client. (Reason: CORS request did not succeed). Status code: (null).
Module source URI is not allowed in this document: “http://localhost:3009/@vite/client”. login:19:80
It appears to redirect to /login just fine and show the name of the app in the browser's tab, so I know it's partially working. But this CORS thing is stopping it cold and I don't know what to do to get past it. Can anyone please help?
EDIT
Even stranger, when cancel out of sail npm run dev, then the app works fine! (Maybe because I ran sail num run build at some point after posting this.) But the moment I start up sail npm run dev, I again get the CORS errors. So confusing!
Please or to participate in this conversation.