Flomp / wanderer

wanderer is a self-hosted trail database. Save your adventures!
GNU Affero General Public License v3.0
1.09k stars 29 forks source link

Bad Gateway Error with direct link #102

Open TheBig-O opened 3 weeks ago

TheBig-O commented 3 weeks ago

Any time I use a direct link to a trail, I get an error saying "Bad Gateway." For example, when paste https://example.com/trail/view/vahveq98siviv66 into the address bar, I get the following in the logs:

[INFO] [03:15:00]: Starting auto-upload
[ERROR] [03:15:00]: Login failed. Unable to obtain cookie.
SvelteKitError: Not found: /trails/view/vahveq98siviv66
    at resolve2 (file:///app/build/server/index.js:4069:18)
    at resolve (file:///app/build/server/index.js:3901:34)
    at Object.handle (file:///app/build/server/chunks/hooks.server-49W1TjIe.js:59:26)
    at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
    at async respond (file:///app/build/server/index.js:3899:22)
    at async Array.ssr (file:///app/build/handler.js:1243:3) {
  status: 404,
  text: 'Not Found'
}

Any idea why it seems to be dumping the cookie. It's acting like I'm not logged in, but I'm definitely logged in and can pull up the trail through the menus. I have no idea why the bad gateway error or what is going on. Thanks for the help fixing this.

Flomp commented 3 weeks ago

That's strange. Does this also happen for you on the demo instance? E.g. https://demo.wanderer.to/trail/view/jmolew6qjtkmx5f

TheBig-O commented 3 weeks ago

So, I tried the link that you provided and it does come up without issue. This makes me think that it has something to do with the setup and reverse proxy I'm using. Each of the main links work as expected from the home page, Trails, Maps, Lists, Home, No Problem! I can get to the individual trails from the Lists page and can see everything about the trail and edit as I like. As soon as I try to use a direct link or refresh the page, I get the "Bad Gateway" error. If I try to modify the link in any way to show a previous trail's link, same error. Refreshing or direct links from anywhere except the main page results in an error. Any thoughts? I've updated my compose to ensure that it exactly matches the one in the repository, with the same single/double quotes, etc. The results are the same.


I'm using NGINX Proxy Manager with no unusual setup, locations, or otherwise. I had "websockets" enabled, but have disabled that. There is no change in the "Bad Gateway" error.

Flomp commented 2 weeks ago

The "Bad Gateway" error is very likely thrown by your NGINX proxy manager. I'm unsure if this can be fixed in wanderer. I tried it with the following config and did not encounter the error you describe.

grafik

TheBig-O commented 2 weeks ago

Hmm... Not sure what's going on. My NPM setup is just like yours and I can't get any direct link to work. I always get a bad gateway error and the logs show:

[ERROR] [00:45:00]: Login failed. Unable to obtain cookie.
SvelteKitError: Not found: /trail/view/
    at resolve2 (file:///app/build/server/index.js:4069:18)
    at resolve (file:///app/build/server/index.js:3901:34)
    at Object.handle (file:///app/build/server/chunks/hooks.server-49W1TjIe.js:59:26)
    at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
    at async respond (file:///app/build/server/index.js:3899:22)
    at async Array.ssr (file:///app/build/handler.js:1243:3) {
  status: 404,
  text: 'Not Found'
}

I use cloudflare for my DNS. Is it possible they're putting something into the mix that's hosing things up?

Flomp commented 2 weeks ago

The Login failed. Unable to obtain cookie. stems from the auto-upload cronjob and is unrelated to your problem. It seems that SvelteKit is not able to find the route for some reason. Does this also happen with public trails, or just the ones tied to your account?

TheBig-O commented 2 weeks ago

So, I tried a direct link with public posts and had no issues. The page came right up. I tried it on several different browsers and it worked in each of them. The public posts that I created work without issue. It appears to only be something that happens with the private trails.

0x3e4 commented 2 weeks ago

i had a similar issue when i sign up with oidc and an user with only 2 char length (pocketbase limitation).. then i uploaded some gfx and i saw them in the database but i couldnt see it in the frontend. even after i fixed the user length the application still faced bad gateway errors at some time/clicks trough the frontend because it wanted to show the uploaded hikes but couldnt connect it to the right user (details) i guess.
fix for me was to recreate the database (or whole application) and use an user with >3 char length from the beginning.

gitmotion commented 23 hours ago

I've been getting this too, i noticed this error only happens when logged in to the site. which i guess makes sense since the log shows it can't obtain the cookie. maybe it's losing the session context on refresh when logged in or something of that nature.

seems like svelte thing. i want to help with a solution to this issue but unfortunately i'm not too familiar with svelte but i found a few links that could be related to the issue https://github.com/sveltejs/kit/issues/9736

potential solution: https://github.com/EmilTholin/svelte-routing/issues/32

Flomp commented 22 hours ago

I cannot recreate the problem on the demo instance or my local test deployments.

wanderer_reload

Anything I need to do differently?

gitmotion commented 20 hours ago

that's very interestinggg not sure what's so different. when im on logged in on demo, the trails list doesn't load on refresh but only loads in after i navigate to the home page and then back to trails. in either case it's not a big issue i suppose since not everyone may be experiencing it? it does make sending links to others a bit tricky. i could be completely wrong but my guess is that the cookie/session is set on the home/root possibly and then it loses it on refresh and only re-sets it after going back to the home page? haven't had time to look into from where that session is stored but maybe it needs to be in a global-ish area if it isn't already that is or how it's interacting with the store. but thanks for looking at this and responding so quickly! overall great job with the app and have been loving it so far!

demo