SvelteKit page keeps on reloading page every 3-4s when serving localhost on https

Viewed 500

I am serving my sveltekit application on https reverse proxied by caddy server on my local machine. Page is being served on https but it keeps on reloading every few seconds.

Command used to serve SvelteKit on https:

npm run dev -- --https

Reverse proxying using caddy server by

caddy reverse-proxy --to http://localhost:3000

How to resolve this?

1 Answers

Here is the issue related to this https://github.com/sveltejs/kit/issues/844

To serve localhost on https, solution is to override the protocol in your svelte kit configuration file

kit: {
        adapter: adapter(),
        vite: {
            server: {
                hmr: {
                    protocol: 'ws',
                }
            }
        },
        // hydrate the <div id="svelte"> element in src/app.html
        target: '#svelte'
    }
 
Related