🤯 TIL: Using Proxy to prevent CORS in Nuxt JS

Published on February 21, 2020

 

When integrating API to frontend, I always encounter the error No ‘Access-Control-Allow-Origin’ header, because of CORS Policy (Content-Resource Sharring Policy) by default browser forbid sharing of content by another domain.

 

Normally, I make a request to the backend person to allow access control origin on their side

 

Native PHP:

 

Laravel CORS for Laravel:

 

Fortunately, there is an option to prevent CORS on Nuxt JS

 

nuxt.config.js

 

With that you don't have to bother the backend person to allow access origin.