Refactor routing and documentation for SPA deployment
- Updated the application to serve the SPA from the root path instead of /map/, enhancing accessibility. - Modified redirect logic to ensure backward compatibility with old /map/* URLs. - Adjusted documentation across multiple files to reflect the new routing structure and API endpoints. - Improved handling of OAuth redirects and session management in the backend. - Updated frontend configuration to align with the new base URL settings.
This commit is contained in:
@@ -355,8 +355,11 @@ onMounted(async () => {
|
||||
props.mapId != null && props.mapId >= 1 ? props.mapId : mapsList.length > 0 ? (mapsList[0]?.ID ?? 0) : 0
|
||||
mapid = initialMapId
|
||||
|
||||
const tileBase = (useRuntimeConfig().app.baseURL as string) ?? '/'
|
||||
const tileUrl = tileBase.endsWith('/') ? `${tileBase}grids/{map}/{z}/{x}_{y}.png?{cache}` : `${tileBase}/grids/{map}/{z}/{x}_{y}.png?{cache}`
|
||||
// Tiles are served at /map/grids/ (backend path, not SPA baseURL)
|
||||
const runtimeConfig = useRuntimeConfig()
|
||||
const apiBase = (runtimeConfig.public.apiBase as string) ?? '/map/api'
|
||||
const backendBase = apiBase.replace(/\/api\/?$/, '') || '/map'
|
||||
const tileUrl = `${backendBase}/grids/{map}/{z}/{x}_{y}.png?{cache}`
|
||||
layer = new SmartTileLayer(tileUrl, {
|
||||
minZoom: 1,
|
||||
maxZoom: 6,
|
||||
@@ -416,9 +419,8 @@ onMounted(async () => {
|
||||
}
|
||||
})
|
||||
|
||||
// Use same origin as page so SSE connects to correct host/port (e.g. 3080 not 3088)
|
||||
const base = (useRuntimeConfig().app.baseURL as string) ?? '/'
|
||||
const updatesPath = base.endsWith('/') ? `${base}updates` : `${base}/updates`
|
||||
// SSE is at /map/updates (backend path, not SPA baseURL). Same origin so it connects to correct host/port.
|
||||
const updatesPath = `${backendBase}/updates`
|
||||
const updatesUrl = import.meta.client ? `${window.location.origin}${updatesPath}` : updatesPath
|
||||
source = new EventSource(updatesUrl)
|
||||
source.onmessage = (event: MessageEvent) => {
|
||||
|
||||
@@ -6,7 +6,7 @@ export default defineNuxtConfig({
|
||||
devtools: { enabled: true },
|
||||
|
||||
app: {
|
||||
baseURL: '/map/',
|
||||
baseURL: '/',
|
||||
pageTransition: { name: 'page', mode: 'out-in' },
|
||||
head: {
|
||||
title: 'HnH Map',
|
||||
|
||||
Reference in New Issue
Block a user