You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Fix Viewer serving non-HTML content in web mode via positron proxy (#8802)
_Originally merged into prerelease/2025.08 in
#8793
---
Addresses #8785
### Before this fix, when running in web mode, the HtmlProxyServer was:
- Reading ALL files (HTML, CSS, JS, images, etc.) as UTF-8 text
- Using `res.send(content)` for all files, which doesn't set proper
`Content-Type` headers
- This caused CSS files to be served as `text/html` instead of
`text/css`, JS files as `text/html` instead of `application/javascript`,
etc.
### Now the code:
- For HTML files: Continues to read them as text and inject HTML
resources if needed (preserving the existing functionality)
- For non-HTML files: Uses `res.sendFile()` with the `root` option,
which automatically sets the correct `Content-Type` headers based on
file extensions
### Why res.sendFile() with root option:
- Built-in MIME type detection that properly maps file extensions to
`Content-Type` headers
- Built-in path traversal protection via the `root` option
- Only HTML files need special processing (resource injection), so other
files can use the standard secure file serving
- Simpler and more secure than manual path validation or dynamic
`express.static()` calls
- This preserves the existing HTML processing while fixing the
Content-Type issue for all other file types.
This should resolve the issue where the proxy was sending back the wrong
`Content-Type` header for non-HTML content like .js or .css files, which
is important if the client is strictly enforcing the MIME type (such as
when `nosniff` was enforced, which is the case in Workbench Positron Pro
sessions).
## New Features
N/A
## Bug Fixes
- Fixed an issue with non-HTML content being served through Positron
Proxy for the Viewer Pane in web mode.
## QA Notes
Need to verify interactive plots in the Viewer function in Positron Pro
in Workbench
@:web
Co-authored-by: Pete <[email protected]>
0 commit comments