mirror of
https://github.com/open-webui/open-webui.git
synced 2026-05-07 03:18:23 -05:00
[PR #9800] [MERGED] WIP Return 404 for non html files #61275
Reference in New Issue
Block a user
Delete Branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
📋 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:
dev← Head:404-non-html📝 Commits (2)
5d68737Return 404 for non html files31ee7a6Only javascript files📊 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.