I'm trying to retrieve a parameter from the URL in the format /:lang/ on the page.
I defined query.lang in the layout page.
In the route, I set the path to /:lang/ and specified the index and layout pages.
Now, in the layout page, I'm trying to read query.lang and display it in a paragraph.
The index page contains “meta name="ac:route" content="/:lang/”
It worked once, and everything was fine.
But after that, I created another route “/” pointing to the index page as well, so the site would also work at the / address.
And everything broke, and I can’t get it to work again. I deleted all the routes and set them up again—it doesn’t work.
I’ll also note that meta tag no longer changes when I delete or modify routes.
What do you recommend?
I read this: Rewriting with URL parameters in NodeJS
(Wapperl 7.9.3, nodejs)
I asked Wappler AI to help me. I told it I was having trouble with the URL parameters and asked it to check what was wrong. I thought it would tell me what was wrong....
First of all, Deepseek isn't working. It's giving an error about the content....
I switched to ChatGPT.
Within 15 minutes, it suggested inserting a meta tag into main.ejs. Then it backed off from that. It loaded route.json and suggested moving the route with the parameter to the end of the list. I agreed. After that, everything started working.
Next, I moved that route back to the top of the list in Wappler (it was also moved there in route.json), and everything continued to work as it should.
It turns out there are no visible changes. I reverted the changes the AI had made. I don’t know if anything was fixed without my knowledge.
The method for fixing the issues works, but it’s completely unclear what the cause was and how it was fixed. And yes, it cost $20.60
for tokens.
If you’re using a URL with a parameter like /:lang/about, you need to configure Query Params in main.ejs. After that, you can access query.lang on your page.
However, you must go to the about.ejs page, open Define Global Data, and simply close it without making any changes. You don’t even need to click “Save.” Only then will the query.lang variable be available. If you don’t know this, you can spend half a day wondering why the site is behaving strangely—some pages work (where you previously just went into Define Global Data out of curiosity) and others don’t.