Avoid CORS requests for a React App

A typical web application architecture

Problem #1

Pre-flight OPTIONS call

Soluion #1

If you’d like to send Authorization headers, your server had better be configured to allow it. Set your server up so it responds to an OPTIONS request at that url with an Access-Control-Allow-Headers: Authorization header.

Problem #2

Soluion #2

Access-Control-Allow-Origin: http://app.example.com

Solution #3

Solution #4

"proxy": "api.exampple.com",

--

--

--

Lead Android Developer, Flutter Lover

Love podcasts or audiobooks? Learn on the go with our new app.

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store
Nabil Mosharraf Hossain

Nabil Mosharraf Hossain

Lead Android Developer, Flutter Lover

More from Medium

What is the difference between react js-and react native — clarification

React App File Structure.

From VanillaJS to ReactJS, Complete React Tutorial EP-1.

Handle Protected Routes in React app with the react-router-dom v6