serve-handler icon indicating copy to clipboard operation
serve-handler copied to clipboard

Redirect http to https?

Open magnus80a opened this issue 6 years ago • 4 comments

Is it possible to do redirect from http to https using redirects? If so, how?

Something like this

redirects: [{
            source: "http://**",
            destination: 'https://**',
            type: 301
        }]

but source is phrased incorrectly or the protocol part cannot be used.

magnus80a avatar Oct 02 '18 08:10 magnus80a

I just debugged it because I was wondering the same. It sends in a relative path for comparison. So redirects is not the way.

MichaelTONeill avatar Feb 26 '19 23:02 MichaelTONeill

Anyone figure out how to do this? I had tried the same as @magnus80a and now I'm here :)

It seems the only other option is creating your own node server.

jflayhart avatar Apr 29 '20 16:04 jflayhart

I'd love for there to be a drop-in serve.json option that would do this every time. Is this something that could be added?

JohnForster avatar Mar 06 '21 09:03 JohnForster

shameless self-promotion alert:
this feature is available in my @warren-bank/serve fork of serve

see: the --force-https option

warren-bank avatar Feb 16 '22 02:02 warren-bank