CORS ERROR in a react nodejs app

hi :wave:
I’m having a cors error when calling one specific backend API route, from my client-side, the app is deployed to Heroku separately server API, and client app
I used Nodejs express PostgreSQL and react
I configured the cors middleware globally to allow API calls for all the APIs, as shown below:


This is the only route that throws cors error in my deployed app, and by the way, in my local development env it works as expected, this route is used to download files from server to client site, the files are hosted in google drive:
corsroute
It took me all night, still couldn’t resolve this issue, thank you in advance🙏

Maybe add OPTIONS cors.methods?

1 Like

Hi thanks, already tried that, all api works except that one I think cors middleware config is overwrited in this route after using res.set headers
corsroute

Now I’m just guessing, but try adding this to cors config:

exposedHeaders: 'File-Extention'

Btw, you have a typo in File-Extention

1 Like

That’s a custum header typo can’t cause cors error, I will try moving the custom header to cors config, thank you

I know, I just wanted to point out a typo :slight_smile:

1 Like

Yeah you are right typo will be fixed👍

I think res.set is overwriting cors config??

This topic was automatically closed 182 days after the last reply. New replies are no longer allowed.