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

netlify serve does not work with an Astro project using SSR and middleware #6720

Closed
whitep4nth3r opened this issue Jun 19, 2024 · 4 comments
Closed
Assignees
Labels
status: triage Issues that need to be combed over type: bug code to address defects in shipped code

Comments

@whitep4nth3r
Copy link
Contributor

whitep4nth3r commented Jun 19, 2024

Describe the bug

I'm trying to debug a production issue where Netlify is not serving the default Astro 404 page.
For example: https://test-default-404.netlify.app/sdfsdf doesn't show the default Astro 404.

Sentry also seems to report this error in production as NoMatchingRenderer. Public link to issue.

In development, running netlify dev and navigating to a legitimate 404 serves the Astro 404 page.

In order to try and see what was going on in production, I attempted to use netlify serve locally.

However, netlify serve, despite showing no errors in the console returns a 404 on ports 8888 (default port which is opened by the CLI in browser), 3999 (as shown for the static server in the console) and 4321 (default Astro port — which I need to use for netlify dev anyway due to using middleware via the Sentry integration).

Steps to reproduce

  1. Clone this project
  2. npm i
  3. Run netlify serve and observe that localhost:8888/3999/4321 returns a 404
  4. Run netlify dev and observe that localhost:4321/asd or localhost:8888/asd returns the default Astro 404

Configuration

[build]
  command = "npm run build"
  functions = "netlify/functions"
  publish = "dist"

Environment

System:
    OS: macOS 14.3.1
    CPU: (12) arm64 Apple M2 Pro
    Memory: 447.11 MB / 32.00 GB
    Shell: 5.9 - /bin/zsh
  Binaries:
    Node: 20.10.0 - ~/.nvm/versions/node/v20.10.0/bin/node
    Yarn: 1.22.22 - ~/.nvm/versions/node/v20.10.0/bin/yarn
    npm: 10.8.1 - ~/.nvm/versions/node/v20.10.0/bin/npm
    pnpm: 9.4.0 - ~/.nvm/versions/node/v20.10.0/bin/pnpm
  npmGlobalPackages:
    netlify-cli: 17.1.0
@whitep4nth3r whitep4nth3r added the type: bug code to address defects in shipped code label Jun 19, 2024
@whitep4nth3r
Copy link
Contributor Author

whitep4nth3r commented Jun 19, 2024

This is also me reporting that Netlify does not serve the correct Astro 404 in production, but was unable to find the correct place to file it, given there's no public repo for the Astro runtime.

I've replicated this using the Node adaptor so disregard this. The issue is with netlify serve only for this issue.

@serhalp serhalp self-assigned this Jul 15, 2024
@serhalp serhalp added the status: triage Issues that need to be combed over label Jul 15, 2024
@serhalp
Copy link
Contributor

serhalp commented Jul 16, 2024

@whitep4nth3r Thanks for reporting this!

This was strictly speaking a limitation in the Netlify CLI: there were flows where it would automatically detect the framework and use the right settings (build command, publish directory, port, etc.) despite an absent netlify.toml with explicit configuration, but netlify serve was not one of those.

Incidentally, all these gaps were just closed this week (#6729)!

If you upgrade to the latest CLI version, you'll see netlify serve working in your demo repo now:

npm install -g netlify-cli@latest

(I was able to confirm this with your demo repo, before and after.)

I'll mark this as fixed, but please feel free to reopen if you're still having issues with this specific issue. Thanks!

@serhalp
Copy link
Contributor

serhalp commented Jul 16, 2024

... Just to be completely clear, since this is rather confusing (I'm confused too!), this issue is about how the index page / returns a 404 when using netlify serve, which is a separate, unrelated issue from withastro/adapters#291, which is about actual non-existing URLs returning a blank 404 page when using netlify serve, astro preview, or deploying to Netlify.

@serhalp serhalp closed this as completed Jul 16, 2024
@whitep4nth3r
Copy link
Contributor Author

Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
status: triage Issues that need to be combed over type: bug code to address defects in shipped code
Projects
None yet
Development

No branches or pull requests

2 participants