WOW!!! Free WorldWide Shipping 🚀

Resolving CORS policy error - What is the Same-Origin policy? and how to bypass it?


What is it?

Examples of same-origin
Examples of same-origin
Examples of different origin
Examples of different origin

How to bypass it

fetch(url, {
method: ‘POST’,
mode: ‘cors’, // no-cors, *cors, same-origin,
headers: {‘Content-Type’: ‘application/json’}
})

Allow CORS: Access-Control-Allow-Origin

// Default = CORS-enabled for all origins 
app.use(cors())
// restrict to certain origin
app.use(cors({origin: “http://localhost:3001"}))

Leave a comment


Please note, comments must be approved before they are published