Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bad Gateway Error with direct link #102

Open
TheBig-O opened this issue Aug 19, 2024 · 10 comments
Open

Bad Gateway Error with direct link #102

TheBig-O opened this issue Aug 19, 2024 · 10 comments

Comments

@TheBig-O
Copy link

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
Copy link
Owner

Flomp commented Aug 22, 2024

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

@TheBig-O
Copy link
Author

TheBig-O commented Aug 23, 2024

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
Copy link
Owner

Flomp commented Aug 24, 2024

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
Copy link
Author

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
Copy link
Owner

Flomp commented Aug 28, 2024

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
Copy link
Author

TheBig-O commented Aug 29, 2024

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
Copy link

0x3e4 commented Aug 30, 2024

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
Copy link

gitmotion commented Sep 13, 2024

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
sveltejs/kit#9736

potential solution:
EmilTholin/svelte-routing#32

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

@Flomp
Copy link
Owner

Flomp commented Sep 13, 2024

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

wanderer_reload

Anything I need to do differently?

@gitmotion
Copy link

gitmotion commented Sep 13, 2024

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants