nginx as dev-proxy to avoid CORS errors

A simple setup for using nginx to avoid CORS errors during local development without the need of code changes.

Going ahead with some modern browser-side rendered frontend development (e.g. React) you may very quickly face the following issue: splitting your project into frontend and backend solutions for development, maintenance, deployment and other purposes, you’ll very likely end up in facing CORS errors during development.

This is because you have to start every single service bound to a different port on your local machine whereas in production environments it is more likely to have all parts hosted under exactly the same domain (precisely: origin) with different paths/contexts which would not lead to any CORS issues at all…

To solve this for your development stage, I provided the following gist showing a simple and feasible solution using nginx as a small proxy to solve CORS issues without the need of changing your code.