nextjs

Hi, I am deploying a nextjs project with /functions to Pages. You can have a preview here at https://q.li2niu.com . But all the apis under /functions return 404 (e.g. https://q.li2niu.com/api/v1/auth/github/redirect )like this post said https://discord.com/channels/595317990191398933/1116287310179352646 . Sadly, the solution is not useful for me. File arch. Build command: npx @cloudflare/next-on-pages@1 Build output directory: /.vercel/output/static Build system version: 1 (latest) Root directory: / I tried to change Build output directory: /.vercel/output, the apis became OK but the static assets of pages are not correctly loaded. Really confused the NotLikeThis
7 Replies
James
James•2y ago
You cannot use the functions directory with @cloudflare/next-on-pages, since we create our own worker to use in the build process. Please move the logic in your functions to Next.js Edge API routes.
Kentđź‘‹
Kent👋OP•2y ago
Thanks I will try this way. If I understand your meanings MeowHeartCloudflare correctly.đź‘Ť
James
James•2y ago
Yeah they need to be moved there but make sure the syntax is also correct https://nextjs.org/docs/pages/building-your-application/routing/api-routes#edge-api-routes
Routing: API Routes
Next.js supports API Routes, which allow you to build your API without leaving your Next.js app. Learn how it works here.
Kentđź‘‹
Kent👋OP•2y ago
Yes. I am following the doc. Correctly export runtime.
Kentđź‘‹
Kent👋OP•2y ago
I have to say your docs are confusing.
Kentđź‘‹
Kent👋OP•2y ago
The deploy is so slow comparing to Vercel. Is there any trick to accelerate the process? Vercel can use cache.
James
James•2y ago
Not as far as I know. We have to do a fresh build of your nextjs app each time, so that part will always be a limiting factor
Want results from more Discord servers?
Add your server