by nickreese · 5y ago · 0 comments
Yet, look at the source and the first thing that pops out is:
// this is a temporary solution until I can figure out a safe way to do this on the server
if (window.location.protocol === 'http:') {
window.location.href = window.location.href.replace('http:', 'https:');
}Also surprising, of course, that an expert isn’t doing that redirect server-side.
https://github.com/kentcdodds/kentcdodds.com/commit/5a747aea...
You generally have two "servers" open, one on port 80, another on 443.
Request on port 80 get a http 301 or 302 to https://${server}${request_uri}
Usually both ports are served by the same daemon, but different vhosts/servers or whatever you want to call it
Rewrite would normally map /arbitrary/ to /something-else/ or similar things, generally transparently so the client never notices
This kind of redirect does not provide the same benefit. An attacker could just tamper with the JS to remove that code, and this could happen on any visit, not just the first.
There are multiple solutions and all of them are even simpler than what he picked.