To the devs: How do you deal with CORS?

in Memehub3 years ago

I have just started building a new React application from scratch, and right off the bat I am getting CORS everyone.

img_2136.webp

I have been working as a dev for like 5 years already and this CORS bullshit gets worse every year and every new app I build.

To those who do not know:
CORS is a security policy adopted by browsers that block a website from making calls (sending or receiving content) from a different origin, that is, another address or server or port.

In my case I am running a basic Express server locally and my React website, I have followed every stackoverflow post and github issue I have found, but the CORS error is still there.

And the most annoying part is that this error happens in an environment that I am obviously only going to use for development, and yet, I still need production levels of security or else no browser will run the app, not even when I explicitly tell both the server and the browser to accept CORS and even the React app what port to use the proxy.

I have apps made a few months ago with similar settings that work perfectly, so the more we update the harder it gets to develop.

AND WHAT DRIVES ME CRAZY IS THAT IT IS OBVIOUSLY A DEVELOPMENT ENVIRONMENT, in production it will obviously all come from the same server and port.

I am seriously thinking about giving up on this career, it is not worth it. We either reinvent the wheel or use libraries built by third parties, which can break your environment in a single update, there is no in between.

Sort:  

The CORS nightmare. I know how yoo feel. My boss has a lot of domains in a single web system where I have to use AJAX from one resource to another.

I thought React was supposed to make our lives easier, but we (I say we because the internet is full of people complaining about the same things) keep falling into the same issues