-
-
Notifications
You must be signed in to change notification settings - Fork 17
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
Update docs for DDEV usage #92
Conversation
I'll add
to this PR. (Discussion: https://discord.com/channels/456442477667418113/456442867163070466/1336287957031718932) Related security advisory: GHSA-vg6x-rcgg-rjx6 |
Updated the PR, a demo repo for this config can be found here as well: https://github.com/mandrasch/ddev-craftcms-vite/blob/main/vite.config.js Ready for review ✅ |
@mandrasch Worth noting that |
@MoritzLost Thanks, very good point! I though about including it, but I doesn't have it included in https://ddev.com/blog/working-with-vite-in-ddev/ for simplicity. But this could/should be added there as well. But I wasn't sure how many users really use additional hostnames in DDEV. Do you know by chance what the implications for |
@MoritzLost Second question
What's your current favorite regex solution? Happy to include here in the PR. |
@mandrasch Probably not too many projects. Though all multi-sites where the sites use more than one domain require additional hostnames to test them in dev. We have a built a couple of sites like this. Not super uncommon for clients to want to maintain multiple brand or company sites, or multiple smaller project websites from one CMS installation.
You could always use the URL of the current site I suppose, though we just always use the primary site to load the dev server: // @var string The public URL to the dev server (what appears in `<script src="">` tags
'devServerPublic' => App::env('PRIMARY_SITE_URL') . ':5173', This will mean all sites will load assets from the devserver via the primary URL, but I haven't encountered any practical downside to this. Except now for the CORS issue, which can be alleviated with the regex setting. For the public server, we use a root-relative path, to ensure that assets are loaded from the current URL when testing a real build and when running on production: // @var string The public URL to use when not using the dev server
'serverPublic' => '/dist/', That's because we don't want The internal dev server URL uses localhost inside the container, anyway: 'devServerInternal' => 'http://localhost:5173/', That's all I think, ping me on Discord if you want more details on this setup :)
Right now I use the regex that @khalwat dropped on Discord: cors: {
origin: /https?:\/\/([A-Za-z0-9\-\.]+)?(localhost|\.local|\.test|\.site)(?::\d+)?$/,
}, Might be slightly overkill, just the part that tests the TLD would probably be sufficient. Now that I think about it, I don't think you need the check for the port number at the end unless you run your local dev domains on a non-standard port. |
@MoritzLost Thanks very much for the detailed answer, much appreciated!
jfyi, DDEV introduced Auto Port Assignment when the standard ports are already in use, therefore a port number could be there for some users. I just checked with https://regex101.com/ ✅ ![]() ![]() For general DDEV usage, I'd propose
I'll update this PR with the general regex, more broader regex though since this is already mentioned in the docs |
Ready for review! ✅ |
Ah this is beautiful, thank you gentlemen. |
New DDEV docs are live now for all 3 Craft versions of the plugin |
Thanks for merging! 🥳 🎉 JFYI, vitejs core team member reviewed our changes and said it's better to use explicitly
Comment by saphire-red ddev/ddev.com#313 (review) As soon as the Vite article PR is out, I'll add another quick PR here for the docs. |
Good idea on the TLD -- though I will say I think we're getting pretty obscure here, and the actual damage/impact of someone using this exploit is limited. |
Description
web_extra_exposed_ports
(https://ddev.readthedocs.io/en/stable/users/extend/customization-extendibility/#exposing-extra-ports-via-ddev-router)vite.config.js
and set it to DDEV primary urlRelated issues
Thanks very much for providing this as Open Source!