fetch failed with app directory
Hey guys, I'm kind of stuck with drizzle at my first try using the app directory.
I have defined the following db query in my page.tsx:
But somehow I always get the error
- error TypeError: fetch failed
Full stack trace:
Node version: v16.13.0
NextJS: 13.4.7
Solution:Jump to solution
Yes!
I found the issue. It was, that somehow the creator of my repository, that I used as template, used
@planetscale/database
, but I was not using planetscale for my dev environment and so it did not work. This now also makes sense with the port 443, which was actually the tried connection to the database url (which was 127.0.0.1 at this moment) and so it did not find any database, because there was none. Now I've changed to drizzle-orm/mysql2 and I will use @planetscale/database
in production...5 Replies
Okay it seems like the normal fetch call is working
My database url is:
mysql://username:password@localhost/dbname
, that should be right?
So I moved my db query to an api route and now i get a little more info to the issue:
Solution
Yes!
I found the issue. It was, that somehow the creator of my repository, that I used as template, used
@planetscale/database
, but I was not using planetscale for my dev environment and so it did not work. This now also makes sense with the port 443, which was actually the tried connection to the database url (which was 127.0.0.1 at this moment) and so it did not find any database, because there was none. Now I've changed to drizzle-orm/mysql2 and I will use @planetscale/database
in production+1