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
Nuxt development server continiously restarts with --https
#12748
Comments
Additional context: Browser logs:
It seems a vite issue. You can use Related: vitejs/vite#1925 |
Hmm, I'm not getting any logs in the browser nor the terminal |
They go away quickly you need to check "preserve logs" to see them 🙈 |
@nandi95 Can you please try this to see if resolves restart issue export default defineNuxtConfig({
vite: {
server: {
hmr: {
protocol: 'ws'
}
}
}
}) |
Screen.Recording.2021-11-09.at.12.53.39.movthere's nothing in the logs to preserve 😬 still the same with the vite config protocol set to websockets |
Having a similar issue behind a Caddy reverse proxy. npx nuxi info
Nuxt CLI v3.0.0-27274229.29599f0 09:55:49
RootDir: /Users/danielhagen/Projects/cashstudio-nuxt3 09:55:50
Nuxt project info: 09:55:50
------------------------------
- Operating System: `Darwin`
- Node Version: `v14.18.1`
- Nuxt Version: `3.0.0-27274229.29599f0`
- Package Manager: `yarn@1.22.17`
- Bundler: `Webpack`
- User Config: `vite`
- Runtime Modules: `-`
- Build Modules: `-`
------------------------------ Console log
With Vite in WSS mode: npx nuxi info
Nuxt CLI v3.0.0-27274229.29599f0 09:59:55
RootDir: /Users/danielhagen/Projects/cashstudio-nuxt3 09:59:55
Nuxt project info: 09:59:55
------------------------------
- Operating System: `Darwin`
- Node Version: `v14.18.1`
- Nuxt Version: `3.0.0-27274229.29599f0`
- Package Manager: `yarn@1.22.17`
- Bundler: `Vite`
- User Config: `-`
- Runtime Modules: `-`
- Build Modules: `-`
------------------------------ Console log
Running Vite in a non-secure WebSocket, as mentioned above by @pi0, results in an error.
|
Actually, the more I thought about it, the thing that was missing was redirecting to the right host for WebSocket. I was able to resolve the error using this in the import { defineNuxtConfig } from 'nuxt3'
// https://v3.nuxtjs.org/docs/directory-structure/nuxt.config
export default defineNuxtConfig({
vite: {
server: {
hmr: {
protocol: 'ws',
host: 'localhost'
}
}
}
}) Still seems like there's an error when Caddy (or the HTTPS flag) tries to proxy the WebSocket back. But at least for now, this is a workaround. |
that doesn't seem to work when using custom configuration like |
I have a Docker stack and an Nginx reverse proxy in it, which proxy pass "/" to "http://client:3000" when i visit https://web.localhost domain. So.... If I use Nuxt3 without Docker and reverse proxy, go to http://localhost:3000, nuxt.config Some idea? |
In case anyone stumbles upon this issue, I solved it by exposing the 24678 port on docker. |
I found a simple solution to this in my nuxt.config.ts - my vite settings now look like this:
It was protocol: 'wss' which did the trick - it needs to be secure, as it is running on https... |
Any way of configuring custom ports - I believe you can on Vite but not sure if this translates onto nitro? Edit: yes, this config worked for me:
|
When running nuxi in https you also need to tell vite where the certificates is. Otherwise you get the constant refreshing issue.
|
You might need to use "sudo" when starting the server too, at least I did.
…On Wed, 18 May 2022, 15:24 Vejron, ***@***.***> wrote:
When running *nuxi* in https you also need to tell *vite* where the
certificates is. Otherwise you get the constant refreshing issue.
In nuxt config something like this should suffice
vite: {
server: {
https: {
key: fs.readFileSync('cert/localhost+2-key.pem'),
cert: fs.readFileSync('cert/localhost+2.pem'),
},
hmr: {
protocol: 'wss'
}
}
},
—
Reply to this email directly, view it on GitHub
<#12748>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/AAE6ENDDKQIEWFK3Q7XPK7DVKTVQJANCNFSM5HVE4MPQ>
.
You are receiving this because you commented.Message ID:
***@***.***>
|
If anyone uses Caddy Revers Proxy and Https in an Development Environment, this fixed my problem. Config Nuxt import { defineNuxtConfig } from 'nuxt';
export default defineNuxtConfig({
vite: {
server: {
hmr: {
protocol: 'wss',
clientPort: 443,
},
},
},
}); Config Caddy
|
In case anyone is using a vscode devcontainer, you'll probably encounter this problem. Thanks for the simple solution |
Now just need to wait until vite reaches v3 and nuxt starts to use it. |
with RC-7 out (vite upgraded) there is still an issue. It just keep polling. |
(The |
Even when configuring using the cli it's still an issue. See the reproduction. |
Not disputing that, just explaining why we don't want configuring |
After nuxt/framework#7680 this now works. with a custom certificate and key the host and wss will now work over https and wss. However, when using only Is this worth reopening as a new issue? |
@nandi95 Good idea. I'll close this one as resolved, and yes, I would appreciate you raising this as a new issue. 🙏 |
I have the same issue and tried to resolve it with pi0 yesterday on discord. It works for him, but I have a suspicion that he, at some point, added the certificates to his OS. Chrome blocks unsigned certificates. This was the issue I reported: #14987 @danielroe maybe worth reopening? |
Each time you restart nuxi, there is a new root certificate chain generated. I will try to investigate on a couple of more browsers and operating systems. |
I think on chrome you can override but the page will stil not work in terms of wss or lazy loading? |
@nandi95 Please try on RC.11. In previous RCs, HTTPS support had two main issues:
|
#12748 If I use a Vite app (without Nuxt3), Vite HMR works fine... On the left : Chrome. On the right : Firefox. About my config :
The Nuxt.config.ts
The Caddyfile :
NuxtApp docker file :
As it's works fine with Chrome, I'm guessing Caddyfile is allright... ? |
@Reivax47 nuxt.config.ts vite: {
server: {
hmr: {
protocol: 'wss',
clientPort: 443,
path: 'hmr/',
},
},
} Caddyfile
|
@tasiotas That did the tricks ! |
Thanks, @tasiotas with your configuration I manage to get it working also in nuxt3 with traefik
vite: {
server: {
hmr: {
protocol: 'wss',
port: 22300,
clientPort: 443,
path: 'hmr/',
timeout: 3,
},
},
}, Docker configuration most important is this traefik.http.routers.vitesocket.rule=Host(`docker.dev.gradio.lv`) && PathPrefix(`/_nuxt/hmr/`) And to expose two ports, otherwise traefik cannot create new service for each port
gradiohead:
container_name: gradio_head
hostname: v5.docker.dev.gradio.lv
image: node:14-alpine
labels:
- traefik.enable=true
- traefik.http.routers.gradiohead_http.service=gradiohead
- traefik.http.routers.gradiohead_http.rule=Host(`docker.dev.gradio.lv`, `v5.docker.dev.gradio.lv`)
- traefik.http.routers.gradiohead_http.entrypoints=http
- traefik.http.routers.gradiohead_http.middlewares=redirect-to-https
- traefik.http.middlewares.redirect-to-https.redirectscheme.scheme=https
- traefik.http.routers.gradiohead.service=gradiohead
- traefik.http.services.gradiohead.loadbalancer.server.port=3000
- traefik.http.routers.gradiohead.rule=Host(`docker.dev.gradio.lv`, `v5.docker.dev.gradio.lv`)
- traefik.http.routers.gradiohead.entrypoints=https
- traefik.http.routers.gradiohead.tls=true
- traefik.http.routers.vitesocket.service=vitesocket
- traefik.http.services.vitesocket.loadbalancer.server.port=22300
- traefik.http.routers.vitesocket.rule=Host(`docker.dev.gradio.lv`) && PathPrefix(`/_nuxt/hmr/`)
- traefik.http.routers.vitesocket.entrypoints=http,https
- traefik.http.routers.vitesocket.tls=true
expose:
- 3000
- 22300
command: >
/bin/sh -c "yarn && yarn dev" And you will get response status |
PR welcome to improve docs for reverse-proxy (nginx, traefik) in development. |
@pi0 can you please point me in which section of docs I can add this example? |
Looks like that from version previously it was connecting to
because we setted in nuxt.config.ts vite.server.hmr.path starting from version
To get it work with traefik loadbalancer i can completely remove two parts from previous config #12748 (comment):
remove vite.server eg vite: {
define: { 'process.env.DEBUG': false },
},
},
remove vitesocket stuff gradiohead:
container_name: gradio_head
hostname: v5.docker.dev.gradio.lv
image: node:14-alpine
labels:
- traefik.enable=true
- traefik.http.routers.gradiohead_http.service=gradiohead
- traefik.http.routers.gradiohead_http.rule=Host(`docker.dev.gradio.lv`, `v5.docker.dev.gradio.lv`)
- traefik.http.routers.gradiohead_http.entrypoints=http
- traefik.http.routers.gradiohead_http.middlewares=redirect-to-https
- traefik.http.middlewares.redirect-to-https.redirectscheme.scheme=https
- traefik.http.routers.gradiohead.service=gradiohead
- traefik.http.services.gradiohead.loadbalancer.server.port=3000
- traefik.http.routers.gradiohead.rule=Host(`docker.dev.gradio.lv`, `v5.docker.dev.gradio.lv`)
- traefik.http.routers.gradiohead.entrypoints=https
- traefik.http.routers.gradiohead.tls=true
expose:
- 3000
command: >
/bin/sh -c "yarn && yarn dev" |
Using For me the solution was to add this: nuxt.config.ts $development: {
vite: {
server: {
watch: {
usePolling: true,
interval: 1000, // set preference
},
},
},
}, Dockerfile EXPOSE 3000 24678
CMD rm -rf /tmp/nitro && npm run dev docker-compose.yml ports:
- 3000:3000
- 24678:24678
environment:
- HOST=0.0.0.0 Make sure to run |
I stumbled on the same issue. My docker-compose also contains the same details. HMR works for components, however, editing and creating changes under /pages and /server for api request or page views is not working for me inside docker, including mac. (See here) Changes for the routing or api endpoints are not updating unless I restart my docker or dev server, this is very annoying. |
For me deleting and reinstalling packages worked.
|
In my case, timeout: 3, solved the problem. / docker with wsl2 |
Environment
Describe the bug
the development server seems to restart all the time
Reproduction
steps:
nuxi init
nuxi dev --host domain.test --https --ssl-key key.pem --ssl-cert cert.pem
Additional context
A similar issue has been described here: #12722
recreating the pkg lock and/or adding the
std-env
package does not helpLogs
No response
The text was updated successfully, but these errors were encountered: