Query string parameters disappear

Hello. I am self-hosting an anvil app. When I put url query strings (e.g. https://some_url.com?key=value), they get removed from the URL and my app doesn’t receive them (https://some_url.com). When I disable Javascript from my browser, they stay, so I believe this problem comes from Anvil.

ezgif-2-725ceb163e

As you can see, when I hit ENTER, the parameters get removed. Anyone know how to fix this?

Anvil apps are Single Page Apps and don’t manage the query string.

Here is how you can use the part after the #: Anvil Docs | Navigation

There is a great module to manage the navigation that uses the same function: HashRouting: Routing, navigation with URL Hash

1 Like

So say, if I put everything in /dashboard, the strings would stay?

You can’t put anything in the url after the app domain.

Everything after the # is intended to be used by the browser. You can use it on the server if you want, but it is not the standard intended use. That’s why Google will ignore it and Anvil apps are not good candidates if you need SEO.

The HashRouting module makes a great misuse of the part after the # and allows you to create permalinks and use the browser history buttons.

I kinda need what’s after the ? since that’s the way Discord sends me a user’s authorization code. Discord Developer Portal

I’m still confused on how to solve this. I just use the Routing module to make a /dashboard and put everything behind that?

What is your workflow?
Does Discord initiate the communication with that url?

Or is that the response to something you started?

EDIT
Perhaps you are looking for http endpoints?

User logs in with Discord → Discord redirects the user to my server code HTTP endpoint with code parameter → the server code redirects user to website with access_code (which disappears and is the problem).

So basically, if I can get the access_code from the string parameters, everything works.

With http endpoints you get all the flexibility you need and you can have many endpoints in an app.

5 Likes