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

vercel dev doesn't render 404 page when X-Content-Type-Options set to nosniff #7788

Closed
1 task
paulrudy opened this issue Jul 24, 2023 · 6 comments
Closed
1 task
Labels
- P3: minor bug An edge case that only affects very specific usage (priority) ecosystem: upstream Upstream package has issue feat: error pages Related to 404 and 500 handling (scope) pkg: vercel Related to Vercel adapter (scope)

Comments

@paulrudy
Copy link
Contributor

paulrudy commented Jul 24, 2023

What version of astro are you using?

2.9.7

Are you using an SSR adapter? If so, which one?

Vercel

What package manager are you using?

pnpm

What operating system are you using?

Mac

What browser are you using?

Chrome, Safari

Describe the Bug

I don't know if this a vercel CLI problem or an @astrojs/vercel adapter issue, but:

In vercel.json, the following entry:

  "headers": [
    {
      "source": "/(.*)",
      "headers": [
        {
          "key": "X-Content-Type-Options",
          "value": "nosniff"
        }
      ]
    }
  ],

causes a custom 404 page to be rendered as raw HTML text, but only when using vercel dev.

Everything works normally when using astro dev and when deployed on Vercel, including with the header in question.

What's the expected result?

Custom 404 page should render.

Link to Minimal Reproducible Example

repo
demo (issue is not present in demo, because issue is only locally when running vercel dev)

Participation

  • I am willing to submit a pull request for this issue.
@github-actions github-actions bot added the needs triage Issue needs to be triaged label Jul 24, 2023
@paulrudy
Copy link
Contributor Author

I see that the 404 and 500 stuff is getting reworked #7754, so perhaps that might address this (admittedly somewhat minor) issue

@natemoo-re
Copy link
Member

Is this running vercel dev or astro dev? The vercel.json settings wouldn't change the astro dev settings. #7754 is only updating the build output, which should be what's deployed to Vercel directly.

@natemoo-re natemoo-re added - P3: minor bug An edge case that only affects very specific usage (priority) pkg: vercel Related to Vercel adapter (scope) and removed needs triage Issue needs to be triaged labels Jul 24, 2023
@natemoo-re
Copy link
Member

I'm guessing this is actually unrelated to the vercel.json settings and this just happens anyway? Maybe only if the file is 404.md instead of 404.astro. But I'm pretty sure #7754 will fix this.

@paulrudy
Copy link
Contributor Author

@natemoo-re thanks for the replies. FYI, I just realized that my minimal reproduction actually doesn't reproduce the issue, sorry about that. Up to you whether you want to leave this issue open or close it, as I may not have time to sort out how to reproduce it minimally. Sorry about the confusion

To answer your questions though, this is only when running vercel dev locally, and removing vercel.json setting does get rid of it. Separately, I'm also noticing that on the live Vercel build, the custom 404 page is rendered but without any styles.

I'll sit tight and see how things shake out after #7754 is merged.

@paulrudy
Copy link
Contributor Author

paulrudy commented Aug 1, 2023

Ok, the issue is still present with Astro version 2.9.7. I've updated the issue with a new (and working) minimal repro.

Separately, I'm also noticing that on the live Vercel build, the custom 404 page is rendered but without any styles.

This separate issue also persists, and I've created #7910 to detail and reproduce it

@natemoo-re natemoo-re added the feat: error pages Related to 404 and 500 handling (scope) label Aug 16, 2023
@lilnasy lilnasy added the ecosystem: upstream Upstream package has issue label Aug 31, 2023
@lilnasy
Copy link
Contributor

lilnasy commented Dec 29, 2023

Since the issue has to do with vercel.json, which astro code doesn't process, and vercel dev which runs its own server, it would seem there isn't something for astro to fix here.

Feel free to reopen if you find something that suggests otherwise.

@lilnasy lilnasy closed this as not planned Won't fix, can't repro, duplicate, stale Dec 29, 2023
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) ecosystem: upstream Upstream package has issue feat: error pages Related to 404 and 500 handling (scope) pkg: vercel Related to Vercel adapter (scope)
Projects
None yet
Development

No branches or pull requests

3 participants