Skip to content

invalid static requests return index.html instead of 404 #9011

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

Closed
eltigerchino opened this issue Feb 12, 2023 · 0 comments · Fixed by #9294
Closed

invalid static requests return index.html instead of 404 #9011

eltigerchino opened this issue Feb 12, 2023 · 0 comments · Fixed by #9294

Comments

@eltigerchino
Copy link
Member

eltigerchino commented Feb 12, 2023

Describe the bug

If the home page / is prerendered, invalid static requests (those matching the paths in _routes.json excluded but are not found) such as /_app/abcd, incorrectly return a 200 status code and the content of the prerendered /index.html file if any.

However, if a 404.html file is found, it is returned alongside the expected 404 status code.

Reproduction

  1. Find a Cloudflare Pages website deployed with @sveltejs/adapter-cloudflare.
  2. Navigate to a non-existent /_app/* URL.

For example, the URL below should return a 404 but returns the prerendered home page:

https://brgh.church/_app/doesntexist

Logs

No response

System Info

System:
    OS: macOS 13.2
    CPU: (8) arm64 Apple M1 Pro
    Memory: 142.81 MB / 32.00 GB
    Shell: 5.8.1 - /bin/zsh
  Binaries:
    Node: 16.18.0 - ~/.nvm/versions/node/v16.18.0/bin/node
    Yarn: 3.2.3 - ~/.nvm/versions/node/v16.18.0/bin/yarn
    npm: 8.19.2 - ~/.nvm/versions/node/v16.18.0/bin/npm
  Browsers:
    Chrome: 110.0.5481.77
    Chrome Canary: 112.0.5586.0
    Firefox: 109.0.1
    Firefox Developer Edition: 110.0
    Safari: 16.3
    Safari Technology Preview: 16.4
  npmPackages:
    @sveltejs/adapter-cloudflare: ^2.0.1 => 2.0.1 
    @sveltejs/kit: ^1.3.10 => 1.3.10 
    svelte: ^3.55.1 => 3.55.1 
    vite: ^4.1.1 => 4.1.1

Severity

annoyance

Additional Information

When the root page is not prerendered, invalid requests to /_app/* return a blank page and a 404.
So, should the Cloudflare adapter include a /404.html by default to ensure this occurs consistently?
Or is it enough to document the importance of including a 404.html page?

@eltigerchino eltigerchino changed the title invalid requests to /_app/* returns unstyled root page instead of 404 invalid requests to /_app/* do not return 404 Feb 12, 2023
@eltigerchino eltigerchino changed the title invalid requests to /_app/* do not return 404 invalid static requests do not return a 404 Feb 12, 2023
@eltigerchino eltigerchino changed the title invalid static requests do not return a 404 invalid static requests return index.html instead of 404 Feb 12, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant