dubinc / dub

Open-source link management infrastructure. Loved by modern marketing teams like Vercel, Raycast, and Perplexity.
https://dub.co
GNU Affero General Public License v3.0
17.5k stars 1.83k forks source link

403 DatabaseError Forbidden when Self-Hosting #1072

Open ash-development opened 1 month ago

ash-development commented 1 month ago

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/@planetscale+database@1.18.0/node_modules/@planetscale/database/dist/index.js:145:0)
    at (../../node_modules/.pnpm/@planetscale+database@1.18.0/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/next@14.3.0-canary.42_@babel+core@7.23.0_@opentelemetry+api@1.8.0_react-dom@18.2.0_react@18.2.0__react@18.2.0/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) 
linear[bot] commented 1 month ago

ENG-441 403 DatabaseError Forbidden when Self-Hosting

ash-development commented 1 month ago

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
h4MeMengoding commented 1 month ago

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

ash-development commented 1 month ago

@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

h4MeMengoding commented 1 month ago

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

steven-tey commented 1 month ago

@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

jhuynh08 commented 1 month ago

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

ash-development commented 1 month ago

@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