Skip to content

fix(desktop): extend CORS workaround to cover Access-Control-Allow-Headers#9753

Open
ricardo777 wants to merge 1 commit intoente-io:mainfrom
ricardo777:patch-1
Open

fix(desktop): extend CORS workaround to cover Access-Control-Allow-Headers#9753
ricardo777 wants to merge 1 commit intoente-io:mainfrom
ricardo777:patch-1

Conversation

@ricardo777
Copy link
Copy Markdown

Description

The allowAllCORSOrigins function already patches Access-Control-Allow-Origin when S3 providers return null. This PR does the same for Access-Control-Allow-Headers.

Problem
Some S3 providers have a hardcoded header whitelist in their server config that doesn't include all headers the desktop app sends (like x-client-version). When this happens, the browser blocks the request before it even goes out:

Request header field x-client-version is not allowed by 
Access-Control-Allow-Headers in preflight response

This broke uploads and downloads completely for me on a hosted setup using FileLu S5 as the S3 backend. The bucket CORS config was correct (*), but the provider's nginx was overriding it with a fixed list — so the bucket config had no effect.

Fix
When Access-Control-Allow-Headers comes back in a preflight response, override it with *. Same pattern as the existing ACAO fix.

Tests

Tested on Ente Desktop v1.7.21 against a self-hosted museum instance with FileLu S5 as the S3 backend.

Before: uploads and downloads failed with x-client-version is not allowed by Access-Control-Allow-Headers in preflight response

After: error is gone, uploads and downloads work as expected.

…-Headers for hosted S3

The allowAllCORSOrigins function already patches Access-Control-Allow-Origin when S3 providers return null. This PR does the same for Access-Control-Allow-Headers.

Problem
Some S3 providers have a hardcoded header whitelist in their server config that doesn't include all headers the desktop app sends (like x-client-version). When this happens, the browser blocks the request before it even goes out:

Request header field x-client-version is not allowed by 
Access-Control-Allow-Headers in preflight response

This broke uploads and downloads completely for me on a hosted setup using FileLu S5 as the S3 backend. The bucket CORS config was correct (<AllowedHeader>*</AllowedHeader>), but the provider's nginx was overriding it with a fixed list — so the bucket config had no effect.

Fix
When Access-Control-Allow-Headers comes back in a preflight response, override it with *. Same pattern as the existing ACAO fix.
@CLAassistant
Copy link
Copy Markdown

CLAassistant commented Mar 23, 2026

CLA assistant check
All committers have signed the CLA.

Copy link
Copy Markdown

@chatgpt-codex-connector chatgpt-codex-connector bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 213977bb6c

ℹ️ About Codex in GitHub

Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".

Comment on lines +673 to +674
} else if (key.toLowerCase() == "access-control-allow-headers") {
headers["Access-Control-Allow-Headers"] = ["*"];
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P1 Badge Preserve explicit ACAH values for checkout traffic

allowAllCORSOrigins now rewrites every Access-Control-Allow-Headers header to *, but this same webContents session is also used for in-app Stripe checkout, and the adjacent comment already documents credentialed XHRs from that flow (desktop/src/main.ts:647-657). For credentialed preflights, browsers do not accept Access-Control-Allow-Headers: *, so a response that previously had a correct explicit allow-list can be turned into an invalid preflight response here, breaking payments again. This needs the same kind of conditional handling as the ACAO workaround instead of unconditionally replacing the server value.

Useful? React with 👍 / 👎.

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

One follow-up question: FileLu returns a valid but incomplete list (e.g. missing x-client-version). The "null" check won't cover that case. Should we also override when the response ACAH doesn't include all requested headers from Access-Control-Request-Headers?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants