Skip to content

Refused to get unsafe header "access-control-expose-headers" on Chrome #2059

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
4 tasks done
alljinx opened this issue Nov 28, 2023 · 21 comments · Fixed by #2095
Closed
4 tasks done

Refused to get unsafe header "access-control-expose-headers" on Chrome #2059

alljinx opened this issue Nov 28, 2023 · 21 comments · Fixed by #2095
Labels
bounty:$20 Bounty applies for fixing this issue (Parse Bounty Program) state:released Released as stable version state:released-alpha Released as alpha version state:released-beta Released as beta version type:bug Impaired feature or lacking behavior that is likely assumed

Comments

@alljinx
Copy link

alljinx commented Nov 28, 2023

New Issue Checklist

Issue Description

Latest Parse SDK (v4.3.1) from "localhost:4200" raise systematically a chrome error Refused to get unsafe header "access-control-expose-headers" when using Cloud.run(...) against a Parse-Server also hosted on localhost.
Issue does not exist with Parse SDK v4.3.0.

Steps to reproduce

Launch a Parse-Server (last version >= v6.4.0).
Use Chrome (or Brave) to make a call to Parse-Server, using the Parse SDK v4.3.1 with the Cloud.run(...) function.

Actual Outcome

Raise a Chrome error Refused to get unsafe header "access-control-expose-headers" for each call using Cloud.run(...)

Expected Outcome

No error as v4.3.0

Environment

NodeJS >= 18

Server

  • Parse Server version: v6.4.0
  • Operating system: Windows 10
  • Local or remote host (AWS, Azure, Google Cloud, Heroku, Digital Ocean, etc): Local

Database

  • System (MongoDB or Postgres): Postgres
  • Database version: 15.x
  • Local or remote host (MongoDB Atlas, mLab, AWS, Azure, Google Cloud, etc): Local

Client

  • Parse JS SDK version: 4.3.1
Copy link

Thanks for opening this issue!

  • 🚀 You can help us to fix this issue faster by opening a pull request with a failing test. See our Contribution Guide for how to make a pull request, or read our New Contributor's Guide if this is your first time contributing.

@PPHelios
Copy link

I have the same issue

@magnacartatron
Copy link

magnacartatron commented Nov 29, 2023

I have the same issue also, I've tried different CORS settings on server side but no luck.

@mtrezza mtrezza added the type:bug Impaired feature or lacking behavior that is likely assumed label Nov 29, 2023
@REPTILEHAUS
Copy link

also getting it now

@mtrezza mtrezza added the bounty:$20 Bounty applies for fixing this issue (Parse Bounty Program) label Dec 26, 2023
@mtrezza
Copy link
Member

mtrezza commented Dec 26, 2023

This header was added in #2033. Maybe someone could investigate this to find out what's wrong with the header implementation. Added a bounty.

@jcabezasia
Copy link

Also I have the same error !!! I wait for the solution :)

@ajmeese7
Copy link

ajmeese7 commented Mar 2, 2024

@mtrezza I experienced this as well, and with some digging I found a Stack Overflow explanation and a possible solution:

'access-control-expose-headers': 'Content-Encoding, X-Parse-Job-Status-Id, X-Parse-Push-Status-Id',

MDN says that Content-Encoding should be used to expose a non-CORS-safelisted response header. I haven't tried adding this at the front of the code in the mentioned PR line and spinning up a Docker instance to test it myself, but it's definitely worth a shot!

Would love to see this fixed, if someone could test this possible solution out that would be great :)

@mtrezza
Copy link
Member

mtrezza commented Mar 2, 2024

Would you want to open a PR to fix this? We could then release an alpha version of the bug fix and others could easily test this out as the pre-release will be published on npm. We also would need a test to prevent a regression bug.

@mortenmo
Copy link
Contributor

According to this article (https://trackjs.com/blog/refused-unsafe-header/), this error is show in chrome/chromium on any attempt at accessing a header that isn't present.

Changing

if (typeof xhr.getResponseHeader === 'function' && xhr.getResponseHeader('access-control-expose-headers')) {

to:

            if (typeof xhr.getResponseHeader === 'function' && xhr.getAllResponseHeaders().indexOf('access-control-expose-headers') >= 0) {

This fixed it for me. it is worth noting it does seem to be just a console message and doesn't really hurt the execution. Previous version of the code did use getAllResponseHeaders as well.

@mtrezza
Copy link
Member

mtrezza commented Mar 17, 2024

Would you want to open a PR?

@parseplatformorg
Copy link
Contributor

🎉 This change has been released in version 5.1.0-alpha.5

@parseplatformorg parseplatformorg added the state:released-alpha Released as alpha version label Apr 22, 2024
@parseplatformorg
Copy link
Contributor

🎉 This change has been released in version 5.1.0-beta.1

@parseplatformorg parseplatformorg added the state:released-beta Released as beta version label May 16, 2024
@parseplatformorg
Copy link
Contributor

🎉 This change has been released in version 5.1.0

@parseplatformorg parseplatformorg added the state:released Released as stable version label May 16, 2024
@fordsteriote
Copy link

fordsteriote commented May 28, 2024

Can we also add this fix to sdk version 4.x.x ?
(fyi, still using Parse v6)
Thanks

@fordsteriote
Copy link

Do we have updates on this to add this fix in Parse SDK version 4.x.x? Thanks

@dplewis
Copy link
Member

dplewis commented Jun 18, 2024

@fordsteriote This issue is basically a warning, it wouldn’t crash your code. You should be good 👍

@fordsteriote
Copy link

Thanks @dplewis

@R3D347HR4Y
Copy link

@dplewis It's a pretty bothersome issue, it completely fills up the console in my case and I cannot upgrade to Parse JS SDK 5.x.x because of the incompatibility with Node 16...
Gonna attempt an upgrade to Node 18 but not sure it will work, please if possible just publish a 4.3.2 with this issue fixed

@llops
Copy link

llops commented Sep 9, 2024

Hi! It seems several of us are stuck on Parse 4 and version 4.3.1 addresses some critical vulnerabilities.
Could you please add the fix included in version 5.1.0 to the 4 branch?
Thanks!

@mtrezza
Copy link
Member

mtrezza commented Sep 10, 2024

We do not have a long-term support policy for older versions of the Parse JS SDK, so there is no back-port planned for this fix. Even if we did have a LTS policy, we would likely only back-port security fixes, as we currently do in Parse Server where we do have a LTS policy. A workaround may be to create a fork and apply the fix yourself, and use that SDK. The fix itself seems to be simple.

@llops
Copy link

llops commented Sep 10, 2024

Hi @mtrezza , understood. Thank you very much for taking the time to explain this.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bounty:$20 Bounty applies for fixing this issue (Parse Bounty Program) state:released Released as stable version state:released-alpha Released as alpha version state:released-beta Released as beta version type:bug Impaired feature or lacking behavior that is likely assumed
Projects
None yet