[PR #9800] [MERGED] WIP Return 404 for non html files #61275

Closed
opened 2026-05-06 04:43:55 -05:00 by GiteaMirror · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/open-webui/open-webui/pull/9800
Author: @rragundez
Created: 2/11/2025
Status: Merged
Merged: 2/12/2025
Merged by: @tjbck

Base: devHead: 404-non-html


📝 Commits (2)

📊 Changes

1 file changed (+5 additions, -1 deletions)

View changed files

📝 backend/open_webui/main.py (+5 -1)

📄 Description

At the moment, if a path does not exist in the application it returns the index.html file with a 200 response. This is common practice for SPAs to have a nice user experience and not reload the page when the user is navigating over the application.

This can create a problem though if the same response is given for other type of files other than HTML, for example .js files in particulat.
A case if that when using caching either in the browser, the load balancer or an enterprise application like Akamai it can disrupt the cache behaviour. For example, on every build the js files are generated with a different name but some cache might have the endpoint call cached together with the JS files that it should serve, but these files might not exist anymore since the name changed, but the response stills gives 200, telling the client system that everything is OK while it is not. In this specific case the file requested will be a javacscript file but the response is an html file and since it return 200 it can trigger mimetype mismatched as it would be expecting a response mimetype text/javascript but it gets a text/html.

This fix makes sure the 200 and index.html response is given by default but only for javascript files it returns a 404.


🔄 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/9800 **Author:** [@rragundez](https://github.com/rragundez) **Created:** 2/11/2025 **Status:** ✅ Merged **Merged:** 2/12/2025 **Merged by:** [@tjbck](https://github.com/tjbck) **Base:** `dev` ← **Head:** `404-non-html` --- ### 📝 Commits (2) - [`5d68737`](https://github.com/open-webui/open-webui/commit/5d68737b31c18306595ac85d399c9d79436599ab) Return 404 for non html files - [`31ee7a6`](https://github.com/open-webui/open-webui/commit/31ee7a68a2ae3f3b9b039523c4f017399df98c28) Only javascript files ### 📊 Changes **1 file changed** (+5 additions, -1 deletions) <details> <summary>View changed files</summary> 📝 `backend/open_webui/main.py` (+5 -1) </details> ### 📄 Description At the moment, if a path does not exist in the application it returns the index.html file with a 200 response. This is common practice for SPAs to have a nice user experience and not reload the page when the user is navigating over the application. This can create a problem though if the same response is given for other type of files other than HTML, for example .js files in particulat. A case if that when using caching either in the browser, the load balancer or an enterprise application like Akamai it can disrupt the cache behaviour. For example, on every build the js files are generated with a different name but some cache might have the endpoint call cached together with the JS files that it should serve, but these files might not exist anymore since the name changed, but the response stills gives 200, telling the client system that everything is OK while it is not. In this specific case the file requested will be a javacscript file but the response is an html file and since it return 200 it can trigger mimetype mismatched as it would be expecting a response mimetype text/javascript but it gets a text/html. This fix makes sure the 200 and index.html response is given by default but only for javascript files it returns a 404. --- <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 2026-05-06 04:43:55 -05: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#61275