DEV Community

Discussion on: Security on localhost?

Collapse
 
djkianoosh profile image
Kianoosh Raika • Edited

Most of the time, you dont really have to do any of these things if you run a simple reverse proxy locally (on port 80 or some other port) and configure it to route traffic elsewhere. You can get really fancy with the routing, but generally the routing is based on 1 of 3 things:

  • path
  • subdomain
  • header(s)

Essentially this is what API gateway's do (and some more), but the core of it is routing, which is typically called reverse proxy. There's a million of these tools out there now. Some are very simple, some are very complex.

The way this avoids CORS issues, is because you always hit your reverse proxy URL (eg., localhost:80 or [your_machine_name]:80), so you stay on your domain always. Zero crossing of domains or ports or protocols, as all traffic from your browser/device goes through this reverse proxy.