fix swagger docs#1457
Conversation
There was a problem hiding this comment.
Pull request overview
This PR fixes swagger documentation routing by preventing nginx from incorrectly serving API-related static files from the frontend directory. The key change adds a negative lookahead pattern to exclude /api paths from the static file location block, allowing them to be properly proxied to the backend where swagger docs are served.
- Added negative lookahead
(?!/api)to static file regex pattern to exclude API paths - Fixed indentation on the server block opening brace
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| try_files $uri /index.html; | ||
| } | ||
| location ~* /[^/]*\.(?:ico|css|js|gif|jpe?g|png|woff2)$ { | ||
| location ~* ^(?!/api)/[^/]*\.(?:ico|css|js|gif|jpe?g|png|woff2)$ { |
There was a problem hiding this comment.
The regex pattern ^(?!/api)/[^/]*\.(?:ico|css|js|gif|jpe?g|png|woff2)$ will only match files directly in the root path (e.g., /style.css, /app.js) but will not match files in subdirectories (e.g., /assets/style.css, /static/app.js).
The pattern /[^/]*\. matches a single slash followed by any characters except slash, then a dot. This means it won't match paths like /static/bundle.js or /assets/logo.png.
If your frontend static files are served from subdirectories, consider using a pattern like:
location ~* ^(?!/api).*\.(?:ico|css|js|gif|jpe?g|png|woff2)$ {
This would match files at any depth while still excluding /api paths.
| location ~* ^(?!/api)/[^/]*\.(?:ico|css|js|gif|jpe?g|png|woff2)$ { | |
| location ~* ^(?!/api).*\.(?:ico|css|js|gif|jpe?g|png|woff2)$ { |
No description provided.