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

SSR routes 404 on Netlify when a non-competing static route uses rest parameter at the root #3

Closed
1 task
regisphilibert opened this issue Jun 30, 2023 · 13 comments

Comments

@regisphilibert
Copy link

regisphilibert commented Jun 30, 2023

What version of astro are you using?

2.7.2

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

Netlify 2.3.0

What package manager are you using?

npm

What operating system are you using?

Mac

What browser are you using?

Chrome

Describe the Bug

On a hybrid project, SSR routes systematically returns 404 on Netlify when a rest parameter is used at the root of the pages directory.

🚫

src/
├─ pages/
│  ├─ [...page].astro (static works)
│  ├─ persons/[id].astro (ssr 404)

src/
├─ pages/
│  ├─ [page].astro (static works)
│  ├─ persons/[id].astro (ssr works)

This problem appears above @astro/netlify 2.2.0, downgrading to said version fixes the issue. Astro version seems irrelevant.

What's the expected result?

SSR routes should work on Netlify regardless of rest parameter dynamic static route at the root.

Link to Minimal Reproducible Example

https://github.com/regisphilibert/astro-issue-repro-netlify-ssr

Participation

  • I am willing to submit a pull request for this issue.
@natemoo-re
Copy link
Member

Additional relevant issue withastro/astro#8121

@alexanderniebuhr
Copy link
Member

Can we confirm that this is still an issue.

@alexanderniebuhr
Copy link
Member

Closing for now, because the Issue seems to be stale. Happy to reopen, if we get new information or confirmation.

@alexanderniebuhr alexanderniebuhr closed this as not planned Won't fix, can't repro, duplicate, stale Nov 10, 2023
@regisphilibert
Copy link
Author

Hey sorry for the delay was slated to work on this this week. (as to reproduce in latest). We still have the problem on most of our sites. I just need to recreate a minimal repo. Thanks for your patience.

@alexanderniebuhr alexanderniebuhr added needs repro Issue needs a reproduction and removed needs response labels Nov 10, 2023
@regisphilibert
Copy link
Author

Hi @alexanderniebuhr I updated the minimal repo to Astro 3.5.0 and @astro/netlify 3.0.4 and was still able to see the problem occur with src/[...page].astro present at the root. Problem goes aways as soon as you rename it to src/[page].astro

Let me know if I can help further and how.

PS: mini repo deployed at https://idyllic-centaur-501e95.netlify.app/

@alexanderniebuhr alexanderniebuhr removed the needs repro Issue needs a reproduction label Nov 12, 2023
@olimination
Copy link

olimination commented Dec 13, 2023

Hi, I could reproduce the same issue in one of our projects using Astro 3.6.4 and Netlify Adapter 3.1.1.

Our setup and config looks as follow:

astro.config.mjs: output: hybrid

pages:

src/
├─ pages/
│  ├─ [...slug].astro (static works)
│  ├─ blog/[...slug].astro (prerender=false, returns 404)
│  ├─ blog/index.astro (prerender=false, works)

@alexanderniebuhr
Copy link
Member

Just letting you know @Skn0tt we might need to validate this with v4

@Skn0tt
Copy link
Contributor

Skn0tt commented Dec 18, 2023

My gut feeling is that v4 should have fixed this, because it implements the SSR Routing in a different way than before that's less likely to lead to this kind of bug. I'll put it on my todo to verify that.

@regisphilibert
Copy link
Author

regisphilibert commented Dec 18, 2023

I've tried to upgrade the minimal repo using @astrojs/upgrade. Upgrade process worked and updated to astro@4.0.6, @astrojs/netlify@4.0.0 but upon building I run into this error:

|- TypeError [ERR_IMPORT_ATTRIBUTE_MISSING]: Module "file:///Users/user/astro-issue-repro-netlify-ssr/node_modules/@astrojs/netlify/package.json" needs an import attribute of "type: json"

@Skn0tt
Copy link
Contributor

Skn0tt commented Dec 18, 2023

That looks like a different error, potentially related to this line where the new adapter is importing the package.json: https://github.com/withastro/adapters/blob/e21ffd29edd63d7f9d7024071f5e933f433a5686/packages/netlify/src/index.ts#L9C10-L9C17

Let me see if I can reproduce that.

@Skn0tt
Copy link
Contributor

Skn0tt commented Dec 18, 2023

Can reproduce. I've opened #104 to track this, and will work on a fix in a bit.

@Skn0tt
Copy link
Contributor

Skn0tt commented Dec 19, 2023

https://github.com/withastro/adapters/releases/tag/%40astrojs%2Fnetlify%404.0.1 should fix the bug you're seeing @regisphilibert. Could you try again?

@regisphilibert
Copy link
Author

🎉 Yes all is good! I'm glad and grateful the Netlify adapter finally got some love with this overhaul! :) We had to give up on any SSR on Netlify because of this...

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

5 participants