Share your repls and programming experiences

← Back to all posts
Redirect to https in Node.js
h
amasad

If you want to make sure your replit site only serves https you can use this middleware.

Voters
0xlvl
StringentDev
AllAwesome497
SilentShadowBla
AndreDouglas
ChungusFam
Kai_Justice
AdCharity
AgastyaSandhuja
MrEconomical
Comments
hotnewtop
SilentShadowBla

"Henlo" Cool tho

AllAwesome497

I made a version of this that works in flask, here it is:

[deleted]

What if I just did this?

if(/^http:\/\//.test(location.href))
location.href = location.href.replace(/^http:\/\//, "https://");

btw, check out https://FOS.StudentFires.repl.co

ChungusFam

Awesome work

AdCharity

wait how does this work with pre-existing middleware (because I have a middleware that checks a JSON file to see if the file is "locked"). I'm concerned that I'll get a "you can't change headers after they've been sent" error, but I'll try it first :P

Edit: works fine but I had to go about some minor changes

MrEconomical

I always put a script in the client-side to do that lol

slip1244

@MrEconomical

lmao

[deleted]

@nithilan4 wait does that work?

slip1244

@TaylorLiang surprisingly yes but only for things like replit that can be http or https

MrEconomical

@TaylorLiang yes - I use

Coder100

mmmm time to make a package to do that

Scoder12

Very cool!