[PR #7458] [CLOSED] feat: Enable CORS for static files #8857

Closed
opened 2025-11-11 18:07:59 -06:00 by GiteaMirror · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/open-webui/open-webui/pull/7458
Author: @juananpe
Created: 11/28/2024
Status: Closed

Base: devHead: devcors


📝 Commits (1)

  • 34cafd8 Feat: Enable CORS for static files

📊 Changes

1 file changed (+11 additions, -3 deletions)

View changed files

📝 backend/open_webui/main.py (+11 -3)

📄 Description

Pull Request Checklist

Before submitting, make sure you've checked the following:

  • Target branch: Please verify that the pull request targets the dev branch.
  • Description: Provide a concise description of the changes made in this pull request.
  • Changelog: Ensure a changelog entry following the format of Keep a Changelog is added at the bottom of the PR description.

Changelog Entry

Description

  • Fixed CORS issues with static files by implementing proper CORS headers handling for FastAPI's static file serving. This resolves the issue where static resources (like favicon.png) couldn't be accessed from different origins during development.

Added

  • Added CORSStaticFiles class to handle CORS headers for static file responses

Changed

  • Modified static file mounting to use CORSStaticFiles instead of default StaticFiles

Fixed

  • Fixed CORS error when accessing static files from different origins (e.g., localhost:5173 accessing resources from localhost:8080). Resolved "Access-Control-Allow-Origin header missing" error for static resources

Screenshots or Videos

Before:
image

After:
image


🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.

## 📋 Pull Request Information **Original PR:** https://github.com/open-webui/open-webui/pull/7458 **Author:** [@juananpe](https://github.com/juananpe) **Created:** 11/28/2024 **Status:** ❌ Closed **Base:** `dev` ← **Head:** `devcors` --- ### 📝 Commits (1) - [`34cafd8`](https://github.com/open-webui/open-webui/commit/34cafd8e223124eaee9ef30b4bea1c36ef2423cd) Feat: Enable CORS for static files ### 📊 Changes **1 file changed** (+11 additions, -3 deletions) <details> <summary>View changed files</summary> 📝 `backend/open_webui/main.py` (+11 -3) </details> ### 📄 Description # Pull Request Checklist **Before submitting, make sure you've checked the following:** - [x] **Target branch:** Please verify that the pull request targets the `dev` branch. - [x] **Description:** Provide a concise description of the changes made in this pull request. - [x] **Changelog:** Ensure a changelog entry following the format of [Keep a Changelog](https://keepachangelog.com/) is added at the bottom of the PR description. # Changelog Entry ### Description - Fixed CORS issues with static files by implementing proper CORS headers handling for FastAPI's static file serving. This resolves the issue where static resources (like favicon.png) couldn't be accessed from different origins during development. ### Added - Added CORSStaticFiles class to handle CORS headers for static file responses ### Changed - Modified static file mounting to use CORSStaticFiles instead of default StaticFiles ### Fixed - Fixed CORS error when accessing static files from different origins (e.g., localhost:5173 accessing resources from localhost:8080). Resolved "Access-Control-Allow-Origin header missing" error for static resources ### Screenshots or Videos Before: ![image](https://github.com/user-attachments/assets/6a628ccc-8de0-4966-838a-f59a3c017a30) After: ![image](https://github.com/user-attachments/assets/479aaa52-6b07-42c9-b159-226e35d28a91) --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
GiteaMirror added the pull-request label 2025-11-11 18:07:59 -06:00
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: github-starred/open-webui#8857