unjs / redirect-ssl

Connect/Express middleware to enforce https using is-https
MIT License
100 stars 15 forks source link

exclude does not match hostname per readme #41

Open curtgrimes opened 3 years ago

curtgrimes commented 3 years ago

The readme currently has this example for using the exclude option:

app.use(redirectSSL.create({
   exclude: ['localhost']
}))

However, redirect-ssl uses req.url which will not include the hostname like "localhost". If I make a request to http://localhost/foobar, req.url will be /foobar and I won't be able to use the exclude option in the way the readme uses it to exclude a request like this one.

samm81 commented 3 years ago

I'm having the same issue

looks like you would have to include the req.headers.host to get the full URL, including 'localhost'

the line that curtgrimes linked (L30) would then become const url = req.headers.host + req.url || ''