[go: up one dir, main page]

Skip to content

Using reverse proxy like Ngrok with Vite HMR #5399

Answered by mattrossman
mattrossman asked this question in Q&A
Discussion options

You must be logged in to vote

I found a solution, though I'm no expert here so take it with a grain of salt. All that's needed is to set server.hmr.clientPort to either 80 (if accessing an "http" ngrok tunnel) or 443 (if accessing an "https" ngrok tunnel). This is because port 80 is the standard http port and 443 is the standard https port. That way when you access your page over ngrok, the HMR code on the client can correctly call back to the tunnel and route back to your local server. There is no need to use the --https flag for vite.

Since I typically use the https tunnel URL, so my config looks like:

import { defineConfig } from 'vite'
import react from '@vitejs/plugin-react'

// https://vitejs.dev/config/
export d…

Replies: 3 comments 2 replies

Comment options

You must be logged in to vote
2 replies
@jsjoeio
Comment options

@RodBrowning
Comment options

Answer selected by mattrossman
Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
0 replies
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
5 participants