0

If the user logs is success in i redirect him to the dashboard.

It used to work ok until i deploy it using tomcat.

now the url is http://localhost:8080/myWar/

so this:

 window.location.href = "/dashboard";

redirects to http://localhost:8080/dashboard

and I get error 404. How do I redirect this dynamically ?

1 Answers1

1

Pathings are usually all the same:

/ - the "root" Path

./ - relative from the file's location

so you need to change window.location.href = "/dashboard"; to window.location.href = "./dashboard";

https://www.coffeecup.com/help/articles/absolute-vs-relative-pathslinks/

Difference between Relative path and absolute path in javascript

edit:

So if your current location is for example myHost/mypath/subpath and you'd execute window.location.href="/myPath" you'd be redirected to myHost/myPath while window.location.href="./myPath" redirects you to myHost/mypath/subpath/myPath.

messerbill
  • 5,499
  • 1
  • 27
  • 38