Now that Glitch supports http AND https, here is a way to force one of them

Expressjs version:!/force-http-or-https
Polka version:!/force-http-or-https-polka

Glitch now supports both HTTP and HTTPS, I did not find any way to force HTTP/HTTPS from the settings so I made this demo project :slight_smile: instructions are in the code!


Fantastic… I was afraid I wouldn’t be able to use my retro gadgets with glitch. The HTTP forcing works.

1 Like

If you’re using Express, paste this code in your server.js file:

function checkHttps(req, res, next){
  // protocol check, if http, redirect to https
    console.log("https, yo")
    return next()
  } else {
    console.log("just http")
    res.redirect('https://' + req.hostname + req.url);

app.all('*', checkHttps)