#500 Error After Deployment on Cloudflare Pages

7 messages · Page 1 of 1 (latest)

pastel nest
#

Hello,

After deploying my project using Cloudflare Pages, I’m encountering a 500 error, and I’m having trouble identifying the root cause.

Here are some details about my setup:

I’m using Astro (v4.16.2) with Cloudflare Pages for deployment.
The project uses several Astro-related packages, including <@&1055234544183287879>/check (v0.9.4), <@&1055234544183287879>/cloudflare (v11.1.0), and <@&1055234544183287879>/db (v0.14.2).
The database is hosted on Turso (libsql).
In local development mode, everything works as expected, and the database connection functions properly when I use the --remote flag locally.

Given that the app works fine locally but results in a 500 error after deployment, I would greatly appreciate any guidance on how to troubleshoot or resolve this issue.

Thank you in advance for your help!

light knot
#

I get 500 error as well on pages with island components that are fetching data. My deployment works on Vercel and Netlify but not working properly with Cloudflare Pages.

polar ore
#

welcome to cloudflare!
to understand what's happening i suggest you go the workers page by clicking from the sidebar, then go to you most recent deployment (view details on the latest deployment), then go to functions, scroll down to "Real-time Logs (Beta)", click the button "Begin log stream" and while the connection is established open a new tab and connect to the .pages.dev subdomain your deployment was deployed. Once you have done that you can come back to the real time logs and see what the server error is!

#

let me know if yall need more support

jovial aspen
#

If you are running output: "server" this might be a limitation with the current astrojs/db package with libSQL. Previously it worked on CF with Studio using libSQL HTTP proxy,

see the note in the AstroDB docs under Connecting to remote databases

Docs

Learn how to use Astro DB, a fully-managed SQL database designed exclusively for Astro.

light knot
# polar ore welcome to cloudflare! to understand what's happening i suggest you go the worke...

It looks like the issue I;m having after reviewing those logs is the page loads the fetch function can't detect the env variable.

"exceptions": [
    {
      "name": "Error",
      "message": "WPGRAPHQL_URL is not set in the environment variables",
      "timestamp": 1729007827029
    }
  ],

This is how I have the env variables set in my astro project. Is it different for Cloudflare Pages SSR?

const WP_API_URL = import.meta.env.WPGRAPHQL_URL;

if (!WP_API_URL) {
    throw new Error('WPGRAPHQL_URL is not set in the environment variables');
}