dub icon indicating copy to clipboard operation
dub copied to clipboard

403 DatabaseError Forbidden when Self-Hosting

Open ash-development opened this issue 1 year ago • 8 comments
trafficstars

i am currently trying to self-host Dub based off of this repo. i am running into the following errors:

 DatabaseError: Forbidden
    at (../../node_modules/.pnpm/@[email protected]/node_modules/@planetscale/database/dist/index.js:145:0)
    at (../../node_modules/.pnpm/@[email protected]/node_modules/@planetscale/database/dist/index.js:81:0)
    at (lib/planetscale.ts:52:4)
    at (lib/middleware/link.ts:69:21)
    at (../../node_modules/.pnpm/[email protected]_@[email protected]_@[email protected][email protected][email protected][email protected]/node_modules/next/dist/esm/server/web/adapter.js:156:0) {
  status: 403,
  name: 'DatabaseError',
  body: { code: 'internal', message: 'Forbidden' }
}
[GET] [middleware: "middleware"] / reason=EDGE_FUNCTION_INVOCATION_FAILED, status=500, user_error=true

i have set up my mysql and planetscale proxy based off of this docker compose file and added them as environment variables in vercel as follows:

DATABASE_URL="mysql://root:@NODEIP:3307/planetscale"
PLANETSCALE_DATABASE_URL="http://root:unused@NODEIP:3900"

the only thing the build logs display as errors are what is below, although i doubt that it is directly related to the error. any help is appreciated, thank you!!

web:build: API error occurred Dynamic server usage: Route /api/analytics/demo couldn't be rendered statically because it accessed `request.headers`. See more info here: https://nextjs.org/docs/messages/dynamic-server-error
web:build:    Generating static pages (16/64) 
web:build: API error occurred Dynamic server usage: Route /api/me couldn't be rendered statically because it accessed `request.headers`. See more info here: https://nextjs.org/docs/messages/dynamic-server-error
web:build: API error occurred Dynamic server usage: Route /api/support/upload couldn't be rendered statically because it accessed `request.headers`. See more info here: https://nextjs.org/docs/messages/dynamic-server-error
web:build:    Generating static pages (48/64) 

ash-development avatar Jul 16 '24 12:07 ash-development

i'd also like to note that the database connects fine when ran with a local dev instance, it simply just fails when deploying in vercel.

this is the error that is displayed on the actual deployed page: Screenshot 2024-07-16 at 8 49 18 AM

ash-development avatar Jul 16 '24 12:07 ash-development

hii @ash-development, have you found a way to fix it?

h4MeMengoding avatar Jul 20 '24 15:07 h4MeMengoding

@h4MeMengoding nope 🤷🏼‍♀️ i just gave up because this was after two days straight of troubleshooting. wasn't THAT worth it to me lol. its very odd that the database works with a dev installation (still via remote SQL database) but not thru prod with hosting on vercel

it seems that support for self-hosting is pretty nonexistent unfortunately

ash-development avatar Jul 21 '24 03:07 ash-development

me too!, 2 weeks ago I tried to find the problem for 1 week in a row, and no results, it seems that dub prioritizes its users only using their web version, maybe

h4MeMengoding avatar Jul 21 '24 10:07 h4MeMengoding

@ash-development what are you using for the MySQL proxy? Where is your MySQL DB hosted on? That could be the source of the error here

steven-tey avatar Jul 26 '24 16:07 steven-tey

I'm also seeing this same issue. Any luck on getting this to work?

jhuynh08 avatar Jul 26 '24 16:07 jhuynh08

@ash-development what are you using for the MySQL proxy? Where is your MySQL DB hosted on? That could be the source of the error here

using both of these via docker compose, had to change the ports as the originals are also running on my server lol https://github.com/ash-development/my-dub/blob/main/apps/web/docker-compose.yml

ash-development avatar Jul 27 '24 06:07 ash-development