wanderer icon indicating copy to clipboard operation
wanderer copied to clipboard

Bad Gateway Error with direct link

Open TheBig-O opened this issue 1 year ago • 10 comments
trafficstars

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.

TheBig-O avatar Aug 19 '24 03:08 TheBig-O

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

Flomp avatar Aug 22 '24 17:08 Flomp

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.

TheBig-O avatar Aug 23 '24 02:08 TheBig-O

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

Flomp avatar Aug 24 '24 17:08 Flomp

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?

TheBig-O avatar Aug 25 '24 01:08 TheBig-O

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?

Flomp avatar Aug 28 '24 10:08 Flomp

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.

TheBig-O avatar Aug 29 '24 01:08 TheBig-O

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.

0x3e4 avatar Aug 30 '24 05:08 0x3e4

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.

  • i've tested this on the demo (while logged in as demo), on refresh of the trails page still loads but the trails don't load in. still doesn't load in after refresh
  • they only load in after navigating to the home page and then navigating back to the trails page

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

  • this issue was raised in the sveltejs repo with the same issue
  • related to: https://github.com/sveltejs/kit/issues/6790 && https://github.com/sveltejs/kit/discussions/6519

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

  • overall i think it suggests using svelte-routing and you need an index.html to add client side routing

gitmotion avatar Sep 13 '24 17:09 gitmotion

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

wanderer_reload

Anything I need to do differently?

Flomp avatar Sep 13 '24 18:09 Flomp

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!

  • side note: sometimes you can see the trails list load for a quick second and then it clears the list. maybe that'll point us in the right direction 🤔

demo

gitmotion avatar Sep 13 '24 19:09 gitmotion

I will close this for now since there have been a lot of updates in between, and I cannot reproduce the issue. If it persists, please feel free to reopen it.

Flomp avatar Apr 23 '25 14:04 Flomp

this seems to have been addressed a while back through an indirect fix. thanks for looking into this!

in retro, its possible the headers size mentioned above could've had some affect

which was also addressed here! https://github.com/Flomp/wanderer/issues/156

in either case seems to be fixed to me 🫡

gitmotion avatar Apr 23 '25 18:04 gitmotion