Skip to content

Commit

Permalink
Merge pull request #99 from mandrasch/patch-2
Browse files Browse the repository at this point in the history
docs: Update DDEV usage - set .ddev.site explicitly for server.cors.origin, add support for custom https_router_port for server.origin
  • Loading branch information
khalwat authored Feb 7, 2025
2 parents 54d21b0 + 1d0fe9d commit 9073262
Showing 1 changed file with 8 additions and 6 deletions.
14 changes: 8 additions & 6 deletions docs/docs/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -372,10 +372,10 @@ server: {
host: '0.0.0.0',
port: 3000,
strictPort: true,
origin: `${process.env.DDEV_PRIMARY_URL}:3000`,
origin: `${process.env.DDEV_PRIMARY_URL.replace(/:\d+$/, "")}:3000`,
cors: {
origin: /https?:\/\/([A-Za-z0-9\-\.]+)?(localhost|\.local|\.test|\.site)(?::\d+)?$/
}
origin: /https?:\/\/([A-Za-z0-9\-\.]+)?(\.ddev\.site)(?::\d+)?$/,
},
}
```
Expand All @@ -391,13 +391,13 @@ use craft\helpers\App;
return [
'checkDevServer' => true,
'devServerInternal' => 'http://localhost:3000',
'devServerPublic' => App::env('PRIMARY_SITE_URL') . ':3000',
'devServerPublic' => preg_replace('/:\d+$/', '', App::env('PRIMARY_SITE_URL')) . ':3000',
'serverPublic' => App::env('PRIMARY_SITE_URL') . '/dist/',
'useDevServer' => App::env('ENVIRONMENT') === 'dev' || App::env('CRAFT_ENVIRONMENT') === 'dev',
// for Vite v4 and below
// for Vite v4 and below
// 'manifestPath' => '@webroot/dist/manifest.json',
// for Vite >= v5
'manifestPath' => '@webroot/dist/.vite/manifest.json'
Expand All @@ -424,6 +424,8 @@ web_environment:

Then be sure to set `criticalUrl` to `http://localhost` as part of your rollup configuration.

For more information about DDEV and Vite, see [Working with Vite in DDEV](https://ddev.com/blog/working-with-vite-in-ddev/).

Finally note that as of DDEV 1.19 you are able to specify Node.js (and Composer) versions directly via `/.ddev/config.yaml`. See more at https://ddev.readthedocs.io/en/stable/users/cli-usage/#nodejs-npm-nvm-and-yarn

In earlier versions of DDEV (< v1.20.0), you had to use a docker-compose file to expose the port. This is not necessary anymore. We leave this guide here as legacy information:
Expand Down

0 comments on commit 9073262

Please sign in to comment.