# Redirects
Date: 2018-10-18
# Scope
Every project in this repo that is deployed to Netlify
# Context
Netlify redirects/rewrites are a powerful tool that we can take advantage of for several usecases:
Avoid preflight (CORS) requests: Since our front and back ends are hosted in different servers/domains, there is normally an extra preflight (options, 204) request for every normal request between them due to CORS policy. Instead of directly accessing the backend domain, we access
frontend.com/api
and redirect it to the backend. This way, all the preflight requests are avoided.Avoid CORS on some domains. Our microservices are normally accessed from Node but, optionally, could be accessed form browsers if using a
frontend.com/microservices
redirection.Prevent adblockers from interfering with analytics. Normally these plugins block requests to well known APIs like Segment or Amplitude. By using
frontend.com/analytics/...
redirection we avoid it.Redirect the default Netlify's project domain to our business domain.