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

Server "Api" routes missing #339

Open
jswhisperer opened this issue Oct 25, 2024 · 14 comments
Open

Server "Api" routes missing #339

jswhisperer opened this issue Oct 25, 2024 · 14 comments
Labels
question Further information is requested

Comments

@jswhisperer
Copy link

Describe the bug
Server "Api" routes missing

https://nuxt-app-gregpalaci.nuxt.dev/ all good
https://nuxt-app-gregpalaci.nuxt.dev/api/books MIA

codebase https://github.com/gregpalaci/nuxty-book
MIA (https://github.com/gregpalaci/nuxty-book/blob/main/server/api/book/%5Bisbn%5D.ts)

Expected behavior
API exists

@atinux
Copy link
Contributor

atinux commented Oct 25, 2024

Where do you deploy your project and with what command?

@atinux atinux added the question Further information is requested label Oct 25, 2024
@jswhisperer
Copy link
Author

npx nuxthub deploy

@jswhisperer
Copy link
Author

Trying some hacking but feels dirty, can I keep the (dynamic) server routes, server rendered on nuxt hub?

import data from "./prisma/seeds.json";
const bookAPI = Object.fromEntries(
  new Map(data.map(({ isbn }) => [`/api/book/${isbn}`, { prerender: true }]))
);

nuxtConfig....

routeRules: {
...bookAPI,
"/api/books": { prerender: true, cors: true },
},


Also tried the experimental.. `defineRouteRules({ prerender: true });`

Copy link
Contributor

atinux commented Oct 26, 2024

By looking at the console it seems you have a 500 on your API route

CleanShot 2024-10-26 at 09.31.23@2x.png

@jswhisperer
Copy link
Author

Thank you so much for taking the time to debug! I know you're a busy guy (we met at a meetup before dotjs in an opera house I think / Paris)

I think I need to rephrase my question, does NuxtHub support the node + Server/ routes as a hybrid app? If so what are the settings I need to do, ssr : false I assume?

Copy link
Contributor

atinux commented Oct 27, 2024

NuxtHub support hybrid rendering by default, no need to set ssr: false 🙂

@atinux
Copy link
Contributor

atinux commented Oct 28, 2024

we met at a meetup before dotjs in an opera house I think / Paris)

I don't remember well but I do hope we will meet again :)

@atinux atinux closed this as completed Oct 28, 2024
@atinux atinux reopened this Oct 28, 2024
@atinux
Copy link
Contributor

atinux commented Oct 28, 2024

Re-opening as the issue might be related to Prisma

@oritwoen
Copy link
Contributor

I don't know if it's related, but when using Drizzle after deploys I also have 500.

On localhost even with remote it works very well without errors.

Zrzut ekranu z 2024-10-28 09-43-57

@jswhisperer
Copy link
Author

I think you are correct it's a prisma issue.

Cannot run exec or something.

Prisma is so finicky.

@jswhisperer
Copy link
Author

Haven't tested but wondering is it because I'm using SQLite with a local file, maybe there is a permissions issue.

cc @oritwoen are you using drizzle with sqlite or remote (real) db?

@oritwoen
Copy link
Contributor

oritwoen commented Nov 9, 2024

Real database from Cloudflare using remote @jswhisperer On dev, i.e. nitro node preset, it works perfectly. With cloudflare-pages preset, something is clearly building incorrectly or pollyfils is missing.

@jswhisperer
Copy link
Author

Super happy to test, I thought cloudflare-pages was required with nuxt-hub
I managed to remove nuxt-hub and also deploy successfully . I'm ok to close this but is there documentation or how does one adjust the presets please.

@jswhisperer
Copy link
Author

Real database from Cloudflare using remote @jswhisperer On dev, i.e. nitro node preset, it works perfectly. With cloudflare-pages preset, something is clearly building incorrectly or pollyfils is missing.

Happy to close, could you specify how to change the presets... I didn't edit anything and it ran cloudflar-pages as a preset. My solution utimateley was to remove nuxt-hub and deploy elsewhere but not ideal obviously! :)

Article https://dev.to/jswhisperer/i-will-refuse-live-coding-interviews-from-now-on-3mfh
heres the code if you want a peak https://github.com/gregpalaci/nuxt-demo-books
and a preview https://lambent-fenglisu-27a5c4.netlify.app/

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

No branches or pull requests

3 participants