Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: add support for base url #1873

Merged
merged 2 commits into from
Jun 9, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion src/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -66,8 +66,11 @@ Vue.use(VueResize)

const initLoad = async () => {
try {
// get base url. by default, it is '/'
const base = import.meta.env.BASE_URL ?? '/'

//load config.json
const res = await fetch('/config.json')
const res = await fetch(`${base}config.json`)
const file = (await res.json()) as Record<string, unknown>

window.console.debug('Loaded config.json')
Expand Down
6 changes: 5 additions & 1 deletion src/plugins/router.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,10 @@ import Vue from 'vue'
import routes from '@/routes'

Vue.use(VueRouter)
const router = new VueRouter({ mode: 'history', routes })
const router = new VueRouter({
base: import.meta.env.BASE_URL,
mode: 'history',
routes,
})

export default router
Loading