Configure pre-fixed url of the application with Tomcat

Asked

Viewed 102 times

1

I developed an application in Vue, managed the folder dist for production and managed to publish it using Tomcat. In this case I played the dist folder generated in the /webapps/helloWorld folder.

I can access through the link

http://localhost:8080/helloWorld 

so far so good. The problem is that the

/helloWorld

only works for the first access, it does not stay as pre-fixed link. It is so much that after the first access the link is like this:

http://localhost:8080/login

In case I want to go to screen home I was supposed to type

http://localhost:8080/helloWorld/home

But it doesn’t work, it just works like this:

http://localhost:8080/home

How do I leave the /helloWorld/ as pre-fixed on all routes?

1 answer

2

It would be interesting for you to host your code or your route settings so we can better understand what might be happening, but this is probably happening because the routes are part of the same "level" of hierarchy, check if the route "home" is being declared inside a "helloworld" Children. It would look something like this:

const router = new VueRouter({
  routes: [
    { path: '/helloworld', component: HelloWorld,
      children: [
        {
          path: 'home',
          component: Home
        }
      ]
    }
  ]
})

Official example of Vue.js in Codepen: https://jsfiddle.net/yyx990803/L7hscd8h/

Source: https://router.vuejs.org/guide/essentials/nested-routes.html

Browser other questions tagged

You are not signed in. Login or sign up in order to post.