Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

Pro tip: you can use any subdomain of localhost (like app1.localhost) to get a separate origin that still resolves to 127.0.0.1

I've found this most useful for testing CORS and similar web features that depend on the origin, but I guess it could be helpful for HTTPS-related things too.



Or even better, you could just route anything to 127.0.0.x locally. E.g. replicate the actual production deployment locally.


Wouldn’t that require having an HTTPS stack and valid production certificates locally?


You don't need valid production certificates, just valid certificates for that domain name, signed by a CA you trust. The nuance is that you can use a local CA to get a valid certificate, rather than using a production one (which you don't want to have on your computer - I mean the private part of it of course)


Yes. The browser cares about names (a number is a name, but a name isn't just a number) the loopback is special (it has "Secure Context" and thus gets the same privileges as URLs with HTTPS schemes) and most systems ensure that the name localhost is always defined to be the loopback so that gets to be special, but some.other.example even if it looks up as 127.0.0.1 is not special, and the browser expects the server it's talking with to prove it is really some.other.example which it probably can't do.


That’s how I do it too. I think at some point I had to because of ServiceWorkers.




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: