Start + https preview server fails on res.setHeaders is not a function
Nobody has claimed this yet.
- Dominant language
- TypeScript
- Stars
- 15.1k
- Forks
- 1.9k
- Avg merge
- 1d 20h
- Merged PRs (30d)
- 143
Description
Which project does this relate to?
Start
Describe the bug
When running the preview server in SPA mode with HTTPS enabled, the server fails to serve the application shell. Instead, it crashes with an error below:
TypeError: res.setHeaders is not a function
at file:///X:/experiments/tanstack-preview-server-https-bug/node_modules/@tanstack/start-plugin-core/dist/esm/preview-server-plugin/plugin.js:31:19
Development server with HTTPS certificates works fine.
Your Example Website or App
https://github.com/susickypavel/tanstack-preview-server-https-bug
Steps to Reproduce the Bug or Issue
- Clone the repository
git clone git@github.com:susickypavel/tanstack-preview-server-https-bug.git
cd ./tanstack-preview-server-https-bug
- Create certificates for
example.localhost
mkdir .certs
cd .certs
mkcert example.localhost "*.example.localhost"
- Add
example.localhostto hosts file
# For Mac or Linux
nano /etc/hosts
127.0.0.1 example.localhost
- Install dependencies and run the preview server
bun install
bun run build:preview
Expected behavior
I'd expect the preview server to work the same way it works for bun dev, but it should use the production files instead.
Screenshots or Videos
No response
Platform
- Router / Start Version: 1.132.0
- OS: Windows
- Browser: All
- Bundler: vite
Additional context
No response
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Clone the linked reproduction, install its dependencies, and run bun run build:preview after creating the HTTPS certificates. Start with the stack-trace location in @tanstack/start-plugin-core/dist/esm/preview-server-plugin/plugin.js, then trace the corresponding preview-server code. Done means the HTTPS SPA preview serves the application shell using the production files without the res.setHeaders error.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- bun, typescript, vite
- Domain
- backend, build-system
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 45/100