Server Side Rendering with PlanetScale and Edge runtime

Hey there! I’m currently trying to develop a webpage with a data the being fetched in the getServerSideProps in next.js, with planet scale (with the @planetscale/database library, this library support edge runtime). I uploaded the website to Cloudflare Pages, but I get this error when I open the page: “Error: Some functionality, such as asynchronous I/O, timeouts, and generating random values, can only be performed while handling a request.” Please someone help me I really need this help.This is the code: export const getServerSideProps: GetServerSideProps = async ({ }) => { const config = { host: process.env.NEXT_PUBLIC_DATABASE_HOST, username: process.env.NEXT_PUBLIC_PS_USERNAME, password: process.env.NEXT_PUBLIC_PS_PASSWORD, }; const conn = await connect(config); const query = SELECT * FROM blogs WHERE slug = 'testing'; const result = await conn.execute(query, [1]); let blogData; if (result.rows.length > 0) { const firstRow = result.rows[0] as { content: any }; // Add type assertion here blogData = firstRow.content; } return { props: { data: blogData, }, }; }; Worth saying it works perfect in my localhost… Thanks! account ID: 5b922673976993617f4baa05c6a28eb2
1 Reply
yat
yat2y ago
why NEXT_PUBLIC ?
Want results from more Discord servers?
Add your server