Unable to browser.goto Route When Already Routed to Sibling Page

Hi.
I have the below routing structure in my SPA.

image
When I am on the requests route page, the URL on browser says “www.domain.com/app/requests”, which is fine.
Now on this page, I need to redirect to the “/F002” route. To do this, when I select the route in a browser.goto() action, the code I get is:
browser.goto('./F002/123')

When this code gets executed on the browser, the application breaks. This is the URL shown in the address bar: “www.domain.com/appF002/123”.

If I MANUALLY change the code in browser.goto as: browser.goto('.//F002/123'), then the page correctly redirects to “www.domain.com/app/F002/123” and the page opens.

How to route to a sibling route page when nested under another route?

1 Like

hello @sid this is old bug … already reported but not yet fixed

Oh. Link?

@patrick: Can you please help?

I have searched the bugs and can’t find any other reference to this exact error. The only other bug that is similar is this one but it is a different issue as far as I can tell.

I have had this issue occur today also. It started with an older version but after updating to 3.5.7 it is still present.

Thanks for digging this up.

@patrick / @Teodor some insight on this would be helpful. Just saw this issue again day before yesterday in 3.5.7. So it has not been fixed yet.
This time it was in ASP.NET server. Originally it was in PHP.

Why not just end your routes with / ?

Interesting. So use ‘/app/’ in main route… and then set ‘/F002/:requestid’ in page route?

Well just add trailing / in your routes …
Screenshot_32

Can you please check the original post again. I think you have misread the issue. Trailing slashes on the page routes don’t help.
broswer1.goto('./requests') when on /app path, just redirects to /apprequests/. What we need is /app/requests.

Well … that is what i am saying - use trailing / in your routes!

/app/ + ./something/ will result in /app/something/.

You can’t expect ./ to add / in your routes … that’s not what it does.

This is confusing. Your screenshots missed to add trailing slash to /app route, as in this code.

This should work is what you mean I think. Adding trailing slash to ‘/F002/:requestid’ would be needed only if there is yet another level of nesting.

Sid, i just missed to add the / there on that screenshot…

So in the last few posts i am just trying to explain to you - add trailing / to your routes. That’s all.

Yeah I followed that. What I am saying is I don’t need to add it to ALL routes. Just the ones that have nesting. /app in my case.
Instead your screenshot added trailing slashes to all the other routes, except the one where it was actually required. Hence the confusion.

Tested by changing /app to /app/ and it works now. Thanks.

1 Like