feat: support path-based deployment for standalone apps

Add VITE_BASE_PATH support to standalone app configs so they can be
served under a path prefix (e.g., app.domain.com/sortir/) instead of
a separate subdomain. This enables shared auth via same-origin
localStorage.

- Vite configs: configurable base path via VITE_BASE_PATH env var
- Routers: use import.meta.env.BASE_URL for history base
- PWA manifests: use base path for start_url and scope
- Default: / (backward compatible with subdomain mode)

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
Padreug 2026-04-27 17:43:49 +02:00
commit 1edea25862
4 changed files with 15 additions and 6 deletions

View file

@ -54,7 +54,7 @@ export async function createAppInstance() {
].filter(Boolean) ].filter(Boolean)
const router = createRouter({ const router = createRouter({
history: createWebHistory(), history: createWebHistory(import.meta.env.BASE_URL),
routes: [ routes: [
// Record page is the home page in standalone mode // Record page is the home page in standalone mode
{ {

View file

@ -50,7 +50,7 @@ export async function createAppInstance() {
].filter(Boolean) ].filter(Boolean)
const router = createRouter({ const router = createRouter({
history: createWebHistory(), history: createWebHistory(import.meta.env.BASE_URL),
routes: [ routes: [
// Activities page is the home page in standalone mode // Activities page is the home page in standalone mode
{ {

View file

@ -33,9 +33,13 @@ function activitiesHtmlPlugin(): Plugin {
/** /**
* Vite config for the standalone Sortir activities app. * Vite config for the standalone Sortir activities app.
* Deployed to sortir.ariege.io *
* Set VITE_BASE_PATH to deploy under a path prefix:
* VITE_BASE_PATH=/sortir/ app.ariege.io/sortir/ (shared auth)
* (default: /) sortir.ariege.io (standalone subdomain)
*/ */
export default defineConfig(({ mode }) => ({ export default defineConfig(({ mode }) => ({
base: process.env.VITE_BASE_PATH || '/',
plugins: [ plugins: [
activitiesHtmlPlugin(), activitiesHtmlPlugin(),
vue(), vue(),
@ -65,8 +69,8 @@ export default defineConfig(({ mode }) => ({
background_color: '#ffffff', background_color: '#ffffff',
display: 'standalone', display: 'standalone',
orientation: 'portrait-primary', orientation: 'portrait-primary',
start_url: '/', start_url: process.env.VITE_BASE_PATH || '/',
scope: '/', scope: process.env.VITE_BASE_PATH || '/',
id: 'sortir-activities', id: 'sortir-activities',
categories: ['social', 'entertainment', 'lifestyle'], categories: ['social', 'entertainment', 'lifestyle'],
lang: 'fr', lang: 'fr',

View file

@ -33,8 +33,13 @@ function castleHtmlPlugin(): Plugin {
/** /**
* Vite config for the standalone Castle accounting app. * Vite config for the standalone Castle accounting app.
*
* Set VITE_BASE_PATH to deploy under a path prefix:
* VITE_BASE_PATH=/castle/ app.ariege.io/castle/ (shared auth)
* (default: /) castle.ariege.io (standalone subdomain)
*/ */
export default defineConfig(({ mode }) => ({ export default defineConfig(({ mode }) => ({
base: process.env.VITE_BASE_PATH || '/',
plugins: [ plugins: [
castleHtmlPlugin(), castleHtmlPlugin(),
vue(), vue(),
@ -64,7 +69,7 @@ export default defineConfig(({ mode }) => ({
background_color: '#ffffff', background_color: '#ffffff',
display: 'standalone', display: 'standalone',
orientation: 'portrait-primary', orientation: 'portrait-primary',
start_url: '/', start_url: process.env.VITE_BASE_PATH || '/',
scope: '/', scope: '/',
id: 'castle-accounting', id: 'castle-accounting',
categories: ['finance', 'business', 'productivity'], categories: ['finance', 'business', 'productivity'],