Skip to content

Instantly share code, notes, and snippets.

@samonzeweb
Created December 27, 2017 11:54
Show Gist options
  • Save samonzeweb/3a932b342732d6fe9baa2255d41764cb to your computer and use it in GitHub Desktop.
Save samonzeweb/3a932b342732d6fe9baa2255d41764cb to your computer and use it in GitHub Desktop.
Proxy API to avoid CORS problems during JS development
# Proxy API to avoid CORS problems during development :
# - Get Caddy from https://caddyserver.com/
# - Put the Caddyfile somewhere with the Caddy executable
# - Change posts, paths, ... as needed
# - Start the Caddy process (without args)
# - Lauch the SPA using the URL http://localhost:8081
localhost:8081
log stderr
# First : the API
proxy /api http://myserver.foo.bar
# Last : the dev server started by npm, yarn, ...
proxy / localhost:8080
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment