Files
lobehub/apps
Innei 49ec5edffb 🐛 fix: resolve desktop upload CORS issue (#11255)
* 🐛 fix: resolve desktop upload CORS issue

Expand CORS bypass to handle all HTTP/HTTPS requests in desktop app.
Previously, CORS bypass only applied to local file server (127.0.0.1),
which caused upload failures when the renderer uses app:// protocol.

Changes:
- Remove Origin header from all requests to prevent CORS preflight
- Add permissive CORS headers to all responses
- Update comments to reflect the new behavior

Resolves LOBE-2581

* 🐛 fix: enhance CORS handling in desktop app

Refine CORS bypass implementation to store and utilize the original Origin header for responses. This change ensures proper CORS headers are added based on the request's origin, improving compatibility with credentialed requests and OPTIONS preflight handling.

Changes:
- Store Origin header for each request and remove it to prevent CORS preflight.
- Add CORS headers to responses using the stored origin.
- Implement caching for OPTIONS requests with a max age.

Resolves LOBE-2581

Signed-off-by: Innei <tukon479@gmail.com>

* 🐛 fix: add onBeforeSendHeaders mock to Browser tests

Enhance the Browser test suite by adding a mock for the onBeforeSendHeaders function in the session's webRequest object. This addition improves the test coverage for CORS handling scenarios.

Signed-off-by: Innei <tukon479@gmail.com>

---------

Signed-off-by: Innei <tukon479@gmail.com>
2026-01-05 22:37:43 +08:00
..