Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(preview): send configured headers #9976

Merged
merged 2 commits into from Sep 5, 2022
Merged

fix(preview): send configured headers #9976

merged 2 commits into from Sep 5, 2022

Conversation

bluwy
Copy link
Member

@bluwy bluwy commented Sep 4, 2022

Description

Fix #9864

Update sirv to send headers in preview.

Additional context

The dev equivalent is set as:

setHeaders(res, pathname) {
// Matches js, jsx, ts, tsx.
// The reason this is done, is that the .ts file extension is reserved
// for the MIME type video/mp2t. In almost all cases, we can expect
// these files to be TypeScript files, and for Vite to serve them with
// this Content-Type.
if (/\.[tj]sx?$/.test(pathname)) {
res.setHeader('Content-Type', 'application/javascript')
}
if (headers) {
for (const name in headers) {
res.setHeader(name, headers[name]!)
}
}
}

I didn't add the ts handling part as those shouldn't happen in preview.


What is the purpose of this pull request?

  • Bug fix
  • New Feature
  • Documentation update
  • Other

Before submitting the PR, please make sure you do the following

  • Read the Contributing Guidelines.
  • Read the Pull Request Guidelines and follow the Commit Convention.
  • Check that there isn't already a PR that solves the problem the same way to avoid creating a duplicate.
  • Provide a description in this PR that addresses what the PR is solving, or reference the issue that it solves (e.g. fixes #123).
  • Ideally, include relevant tests that fail without this PR but pass with it.

@bluwy bluwy added the p3-minor-bug 🔨 An edge case that only affects very specific usage (priority) label Sep 4, 2022
@bluwy bluwy marked this pull request as draft Sep 4, 2022
@bluwy
Copy link
Member Author

bluwy commented Sep 4, 2022

It looks like the test previously failed because the tests aren't using Vite preview, but a custom static server, so I can't test the preview server (though I can confirm it works locally).

@bluwy bluwy marked this pull request as ready for review Sep 4, 2022
@patak-dev
Copy link
Member

patak-dev commented Sep 4, 2022

Not for this PR, but I think we could move the tests to use vite preview, no? They may not be using it only because the preview server is a feature that was developed after the original e2e test infra.

@bluwy
Copy link
Member Author

bluwy commented Sep 5, 2022

Yeah that's definitely a followup we should do. It feels odd that we're not using it.

@bluwy bluwy mentioned this pull request Sep 5, 2022
@patak-dev patak-dev merged commit 0d20eae into main Sep 5, 2022
12 checks passed
@patak-dev patak-dev deleted the fix-preview-headers branch Sep 5, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
p3-minor-bug 🔨 An edge case that only affects very specific usage (priority)
Projects
None yet
Development

Successfully merging this pull request may close these issues.

vite preview … server does not send configured headers
2 participants