-
Notifications
You must be signed in to change notification settings - Fork 1
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Simplify vite.php config (look into CORs issues too) #80
Comments
I may have been wrong about the change to This
|
Not sure if this is the right ticket but I was using your great blog article to dip my toes into using Vite inside the DDEV container and fell into a CORS issue. See this article for info: https://dev.to/mandrasch/vite-is-suddenly-not-working-anymore-due-to-cors-error-ddev-3673 But it seems like there was a security issue with Vite before and so now you need to add:
into your I also changed to using the simplified $host as specified up there as I'm currently using DDEV with a custom port and the previous version would try and add 2 ports to the end of the URL :) |
Thank you @robzor @joshuapease I just checked out the Craft Vite docs and Andrew Welch has updated the ports and config to include that change but also that the ports in ddev/config are flipped from these ones. https://nystudio107.com/docs/vite/#using-ddev
(note https and container_port are the same)
(again here the ports are the https and container_port values, not http and container_port)
|
Yeah his example didn't work for me until I changed the port to match yours (e.g. Use the HTTPS one for the dev server) |
Run `ddev install` with the @latest flag on all dependencies.
The config can be way simpler if you only allow access from https
Thanks for all your notes @robzor and @maxfenton Here's where I've landed with a PR. |
One thing to add to this, because I am running DDEV on a custom port, I have both regex things in the JS config and Plugin config:
and
Might be worth adding those? :) |
@robzor I had a deploy error when I tried something that included |
Hm, that's interesting, I would've thought that on the production environment it should ignore that whole server section, maybe that's a FR for the Vite guys. |
@robzor I think that's just an error that's inherent to the order that JavaScript executes.
Optional chaining is a good fix. I've never needed to run DDEV in a custom port. Does that port show up in your Would it work to use the |
hi @joshuapease yeah, DDEV populates the .env with the custom port which is nice. I tried changing |
- Add regex replacmenets to allow for custom DDEV ports - Switch port numbers to match nystudio docs. - https://nystudio107.com/docs/vite/#using-ddev - Use DDEV_PRIMARY_URL in vite.config.js - We don't need loadEnv anymore
@robzor Gotcha... those ports are immediately removed by the regex right? Seems like the main benefit is that you don't need to use I think that's benefit is worthwhile. I also like being aligned with the nystudio docs wherever possible. @maxfenton @robzor I made a few tweaks to that PR to account for your feedback
|
Mine is an ongoing concern, as this is my first project properly diving into Vite, but my config is currently looking like this:
|
Just to add to this, I've tried to deploy this to Servd and I'm getting an error with |
Ah, got it working by adding this:
and changing the origin line to:
|
@robzor I think that's equivalent to:
where the optional chaining is doing the same as your ternary logic. |
I tried that a few days ago and it didn't work for some reason |
While Slacking with @maxfenton it seems like this:
Can be simplified to
Max also noted some potential CORs issues (that may or may not be related to this change)
The text was updated successfully, but these errors were encountered: