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

Cloudflare adapter with prerender = true breaks all routing #5831

Closed
1 task done
ni554n opened this issue Jan 11, 2023 · 5 comments · Fixed by #5993
Closed
1 task done

Cloudflare adapter with prerender = true breaks all routing #5831

ni554n opened this issue Jan 11, 2023 · 5 comments · Fixed by #5993
Assignees
Labels
- P4: important Violate documented behavior or significantly impacts performance (priority)

Comments

@ni554n
Copy link

ni554n commented Jan 11, 2023

What version of astro are you using?

1.9.1

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

Cloudflare

What package manager are you using?

npm

What operating system are you using?

Linux

Describe the Bug

After enabling the experimental prerender flag and adding export const prerender = true; in the index.astro file; running astro build and astro dev works as expected.
But all route paths completely fails with 404 with Wrangler Dev as well as on the CF Pages after a successful deployment.

I think there's an issue with the generated _worker.js function. Routing starts working again if I delete that file or, set prerender = false.

Upgrading to [email protected] with @astrojs/[email protected] didn't fix the issue also.

Link to Minimal Reproducible Example

https://stackblitz.com/edit/node-3m5z2c

Participation

  • I am willing to submit a pull request for this issue.
@matthewp matthewp self-assigned this Jan 11, 2023
@matthewp
Copy link
Contributor

I think this is fixed by #5822, going to test it once that is released.

@gacek1123
Copy link

Running into the same issue with "astro": "2.0.0-beta.3" and "@astrojs/cloudflare": "6.0.0-beta.1".

@matthewp
Copy link
Contributor

Thanks for the reminder, this might be similar to #5860, i'll take a look.

@matthewp matthewp added the - P4: important Violate documented behavior or significantly impacts performance (priority) label Jan 19, 2023
@matthewp
Copy link
Contributor

My WIP branch is here: https://github.com/withastro/astro/tree/cloudflare-prerender

just debugging so far, no fix found.

@ni554n
Copy link
Author

ni554n commented Jan 27, 2023

The fix is working great. Thank you. But I've bumped into another issue.

In one of my API routes, I have a library for generating JWT on CF that uses Web Crypto API; which is not available on Node 18.
As soon as I turn on the prerender flag on index.astro, astro build fails throwing prerendering static routes. error SubtleCrypto not supported! even though I have not enabled prerendering on that API route. Is this an intended behavior or a bug?

Please take a look at this example: https://stackblitz.com/edit/node-6ayeta

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
- P4: important Violate documented behavior or significantly impacts performance (priority)
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants