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 integration with theme may be broken #44

Closed
mailman-2097 opened this issue Mar 7, 2023 · 5 comments
Closed

Cloudflare integration with theme may be broken #44

mailman-2097 opened this issue Mar 7, 2023 · 5 comments

Comments

@mailman-2097
Copy link

mailman-2097 commented Mar 7, 2023

I am getting a lot of errors when running the npm run build.

I tried the following options to triage the issue:

a. changed the node versions using nvm, but now pegged to latest v16.19.1 lts/gallium release

I could not use v18 as cloudflare build fails with node 18.

b. Did a diff of all the changes from the original template and my current project, to rule out any disruptive changes.

The major change is the cloudflare integration and the changes in the package and package-lock files

Raised a support request with Astro team on discord.
The theme works as expected; the original template has no issues with npm run build on lts/gallium

Cloudflare integration may be the issue.

build.error.log

@satnaing
Copy link
Owner

satnaing commented Mar 7, 2023

Hello @mailman-2097

If you're not having any advantages provided by SSR, it's recommended to host AstroPaper as a static site directly on Cloudflare Pages instead of using @astro/cloudflare SSR adapter. In this way, you'll have all the features of AstroPaper such as automatic sitemap generation, dynamic OG image generation etc.
This is because SSR has some limitations when it comes to dynamic endpoints. For more info, check this issue.

However, if you only want to use SSR for some reason, you can do the following

  1. Disable dynamic OG image generation.
    At the moment, AstroPaper doesn't provide an option for disabling dynamic OG image generation feature yet. In order to do so, you can simply remove src/pages/[ogTitle].svg.ts file.
  2. Define routes in customPages of sitemap.
    This is not mandatory; but if you want your sitemap to be working properly, you can provide your routes inside customPages option.
// astro.config.mjs
...
    sitemap({
      customPages: ['https://nishad-link.pages.dev//posts/post-1', 'https://nishad-link.pages.dev//posts/post-2']
    }),

Your build process should be working fine after these step.

Above methods resolve your problems hopefully. If you still have some problems, let me know.

@mailman-2097
Copy link
Author

mailman-2097 commented Mar 8, 2023

Hi @satnaing,

Many thanks for your response. Fortunately, I will close the issue.

I realised today the Cloudflare integration was for SSR support, which is not something I need. So I just ripped it out.
✨Build issue resolved. ✨

This is my first Nodejs project, hence the problem was not obvious to me and you were able to call this out as well.
SSR, SSG all so confusing 😕.

But many thanks for your support.

franchb pushed a commit to franchb/blog that referenced this issue Mar 11, 2023
Disable Cloudflare SSR, see satnaing#44
@eerison
Copy link
Contributor

eerison commented Oct 7, 2024

hey @mailman-2097

just for your information I am deploying on cloudflare pages, you can checkout my repository if you want :)

https://github.com/shield-wall/erison-work

@mailman-2097
Copy link
Author

Sure will do. Thank you for the note. 👍

@eerison
Copy link
Contributor

eerison commented Oct 7, 2024

and regarding node version , yeah I got the same issue, then I decided to build the project on github actions, because I can define the node version
https://github.com/shield-wall/erison-work/blob/master/.github/workflows/ci.yml#L42

and after generate the dist folder with the static site, I deploy the files on cloudflare page
https://github.com/shield-wall/erison-work/blob/master/.github/workflows/deploy.yml#L69

unfurtunally you can't use the default integration from cloudflare, otherwise you gonna build your project on that, and you gonna be stuck on this node version problem :/

then I would suggest you deploy via pipelines, it leads more work but you have full control.

I hope it helps you :)

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

No branches or pull requests

3 participants