Passing arguments through url

Hello everyone.
I have a game that has different modes. I need to open the different modes of the game through url.
For example:
Now when I open the game URL is http://localhost:7456.
I want something like http://localhost:7456/?mode=0 or http://localhost:7456/?mode=1
which opens the game in that mode.

Thank You

you don’t need a cocos-specific solution for this, you can use standard JS solutions.

So, in a start scene or something like that, you can do the logic to split between modes. If you are trying this and is not working, in the links you provided, there is a ‘/’ before the ‘?’, and it shouldn’t have. http://localhost:7456?mode=0

Thank you for your reply.

I tried this, now I’m trying to pass the config data in a JSON file by encoding it in the URL.

@Randomzord Is it possible to play the game which opens an encoded URL instead of a default URL like http://localhost:7456/

For example I have a config file in JSON { "game_restart": true}, after encoding it becomes %7B%20%22game_restart%22%3A%20true%7D
So when I play the game instead of the default URL http://localhost:7456/, it should open
http://localhost:7456/%7B%20%22game_restart%22%3A%20true%7D.
Thank you

Everything that comes after the ‘/’ is considered another path inside the URL. In basic therms, you are trying to find some file called %7B%20%22game_restart%22%3A%20true%7D inside your build folder (this is oversimplification, not exactly like that).

Instead of ‘/’ you should do ‘?’ and try to get the content. But even it is not a good solution.

Do you really need to pass this amount of information on the URL? Can’t you have a bunch of config files on the project and pass an argument to select it?

http://localhost:7456?game_mode=1

Thank you for your reply.
I used fetch() API and placed the config file in the build folder.