0

I've deployed a VueJS project to a domain like www.example.com, however, I want to move it to a subfolder so that I can access it like www.example.com/v1

How can I set the base URL or root URL of a VueJS project?

Note: It's not about the base URL for Vue-resource

1 Answer 1

1

You can use option base as /v1/ to move all routes to have base as /v1/.

The base URL of the app. For example, if the entire single page application is served under /app/, then base should use the value "/app/".

Old

How about moving all your routes to nested route, with parent route being /v1:

const router = new VueRouter({
  routes: [
    { path: 'v1', component: BaseView,
      children: [
        {
          // UserProfile will be rendered inside BaseView's <router-view>
          // when /v1/profile is matched
          path: 'profile',
          component: UserProfile
        },
        {
          // UserPosts will be rendered inside BaseView's <router-view>
          // when /v1/posts is matched
          path: 'posts',
          component: UserPosts
        }
      ]
    }
  ]
})
Sign up to request clarification or add additional context in comments.

6 Comments

Hmm. Don't know whether this is the best solution. No other easy way?
@GijoVarghese you can use base option in the route object, check my update.
But how can I set the base URL?
Ok, I've set the base url in router. But still after building, in the index.html file, the resource files doesn't start with /v1
Yes, it does not seems to work as I had expected it, not yet sure why.
|

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.