From dfeff26f6cade655b21eaaddb996f4b170d464da Mon Sep 17 00:00:00 2001 From: Jeremy Stepanek <119798452+cima-alfa@users.noreply.github.com> Date: Tue, 24 Jun 2025 22:28:09 +0200 Subject: [PATCH 1/5] added nette assets --- assets/en/vite.texy | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/assets/en/vite.texy b/assets/en/vite.texy index 781e62016a..041e680967 100644 --- a/assets/en/vite.texy +++ b/assets/en/vite.texy @@ -288,6 +288,24 @@ export default defineConfig({ Actually, even in this case, you need to configure CORS because the dev server runs on the same hostname but on a different port. However, in this case, CORS is automatically configured by the Nette Vite plugin. +If you run Vite inside a container, you might need to set the server host options to `true` or `0.0.0.0`. The Nette Vite plugin will automatically generate the dev server url using `localhost`. + +Optionally, you can set the plugin host option to use another domain. + +```js +export default defineConfig({ + // ... other config ... + + plugins: [ + nette({ + host: 'http://myapp.local' // same as your PHP app + }) + ], + server: { + host: true, + }, +}); +``` HTTPS Development ----------------- From 5fb47151ad36524e28cc2fb204d1ad1f9f18c989 Mon Sep 17 00:00:00 2001 From: Jeremy Stepanek <119798452+cima-alfa@users.noreply.github.com> Date: Tue, 24 Jun 2025 22:30:17 +0200 Subject: [PATCH 2/5] added nette assets --- assets/en/vite.texy | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/assets/en/vite.texy b/assets/en/vite.texy index 041e680967..9043f0d65d 100644 --- a/assets/en/vite.texy +++ b/assets/en/vite.texy @@ -288,7 +288,7 @@ export default defineConfig({ Actually, even in this case, you need to configure CORS because the dev server runs on the same hostname but on a different port. However, in this case, CORS is automatically configured by the Nette Vite plugin. -If you run Vite inside a container, you might need to set the server host options to `true` or `0.0.0.0`. The Nette Vite plugin will automatically generate the dev server url using `localhost`. +If you run Vite inside a container, you might need to set the server host option to `true` or `0.0.0.0`. The Nette Vite plugin will automatically generate the dev server url using `localhost`. Optionally, you can set the plugin host option to use another domain. @@ -298,7 +298,7 @@ export default defineConfig({ plugins: [ nette({ - host: 'http://myapp.local' // same as your PHP app + host: 'myapp.local' // same as your PHP app }) ], server: { From 69a9bbad95d07f301db9157f39826464425647ea Mon Sep 17 00:00:00 2001 From: Jeremy Stepanek <119798452+cima-alfa@users.noreply.github.com> Date: Thu, 26 Jun 2025 19:51:01 +0200 Subject: [PATCH 3/5] Added Docker Development section --- assets/en/vite.texy | 31 +++++++++++++++++++++++++++++++ 1 file changed, 31 insertions(+) diff --git a/assets/en/vite.texy b/assets/en/vite.texy index 9043f0d65d..cdd2dfa27f 100644 --- a/assets/en/vite.texy +++ b/assets/en/vite.texy @@ -307,6 +307,37 @@ export default defineConfig({ }); ``` + +Docker Development +------------------ + +If you run your application inside Docker containers during development, you should [expose |https://docs.docker.com/get-started/docker-concepts/running-containers/publishing-ports/] the Vite port. + +It is also necessary to configure Vite in a way that allows you to make requests to the dev server from your host machine: + +```js +export default defineConfig({ + // ... other config ... + + plugins: [ + nette({ + host: 'myapp.local' // same as your PHP app + }) + ], + server: { + host: '0.0.0.0', // or true + port: 5173, // same as the port you exposed from your Docker container + strictPort: true, // Vite should not start if the port is not available + watch: { + usePolling: true, // set this if Vite does not pick up on file changes (may consume more resources) + }, + }, +}); +``` + +If you develop on a domain other than `localhost`, make sure to include it in the `host` option of the Nette Vite plugin. Otherwise you will run into CORS issues. + + HTTPS Development ----------------- From c7380599c6f967746808cb3083fac2d318b84c26 Mon Sep 17 00:00:00 2001 From: Jeremy Stepanek <119798452+cima-alfa@users.noreply.github.com> Date: Thu, 26 Jun 2025 23:06:06 +0200 Subject: [PATCH 4/5] clarified some details, added links to reference other related configurations --- assets/en/vite.texy | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/assets/en/vite.texy b/assets/en/vite.texy index cdd2dfa27f..415a946bf5 100644 --- a/assets/en/vite.texy +++ b/assets/en/vite.texy @@ -288,9 +288,11 @@ export default defineConfig({ Actually, even in this case, you need to configure CORS because the dev server runs on the same hostname but on a different port. However, in this case, CORS is automatically configured by the Nette Vite plugin. -If you run Vite inside a container, you might need to set the server host option to `true` or `0.0.0.0`. The Nette Vite plugin will automatically generate the dev server url using `localhost`. +**Option 3: Run Vite inside a container** -Optionally, you can set the plugin host option to use another domain. +If you run Vite inside a container, you will need to set the server host option to `true` or `0.0.0.0`. The Nette Vite plugin will automatically generate the dev server url and CORS origin using `localhost`. + +Optionally, you can set the plugin host option to use another domain. Check out the [#Docker Development] section for more information. ```js export default defineConfig({ @@ -321,11 +323,11 @@ export default defineConfig({ plugins: [ nette({ - host: 'myapp.local' // same as your PHP app + host: 'myapp.local' // same as your PHP app - will be used for the CORS origin, allowed hosts and dev server url }) ], server: { - host: '0.0.0.0', // or true + host: '0.0.0.0', // or true, necessary to properly resolve the dev server and cannot be set to a custom domain port: 5173, // same as the port you exposed from your Docker container strictPort: true, // Vite should not start if the port is not available watch: { @@ -335,7 +337,9 @@ export default defineConfig({ }); ``` -If you develop on a domain other than `localhost`, make sure to include it in the `host` option of the Nette Vite plugin. Otherwise you will run into CORS issues. +The `allowedHosts` and `cors` options are handled by the Nette Vite plugin for you. Ofcourse, you are welcome to configure them manually. + +If you develop on a domain other than `localhost`, make sure to include it in the `host` option of the Nette Vite plugin. Otherwise you will run into [CORS issues#Working on Different Domains]. HTTPS Development From 508c80441d4d2b31e20054d717eb47e6dd413d56 Mon Sep 17 00:00:00 2001 From: Jeremy Stepanek <119798452+cima-alfa@users.noreply.github.com> Date: Thu, 26 Jun 2025 23:12:35 +0200 Subject: [PATCH 5/5] removed unnecessary backticks --- assets/en/vite.texy | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/assets/en/vite.texy b/assets/en/vite.texy index 415a946bf5..d561b1b3dd 100644 --- a/assets/en/vite.texy +++ b/assets/en/vite.texy @@ -337,9 +337,9 @@ export default defineConfig({ }); ``` -The `allowedHosts` and `cors` options are handled by the Nette Vite plugin for you. Ofcourse, you are welcome to configure them manually. +The allowed hosts and CORS server options are handled by the Nette Vite plugin for you. Ofcourse, you are welcome to configure them manually. -If you develop on a domain other than `localhost`, make sure to include it in the `host` option of the Nette Vite plugin. Otherwise you will run into [CORS issues#Working on Different Domains]. +If you develop on a domain other than `localhost`, make sure to include it in the host option of the Nette Vite plugin. Otherwise you will run into [CORS issues#Working on Different Domains]. HTTPS Development