Serves public website, admin SPA, and API from a single host
Shared hosting (e.g. mijnhostingpartner.nl) typically allows only one site/app-pool, so SlpModularCms.Api now serves everything itself: '/' for the customer's public website (deployed separately, not part of this repo), '/admin' for the CMS admin SPA, and '/api/v1' for the API as before. - Program.cs: static files from wwwroot + SPA fallbacks per path so client-side routing works for both frontends. - frontend/: builds with base '/admin/' in production (dev unchanged), router basepath follows suit. - SlpModularCms.Api.csproj: publish now builds the admin frontend and copies its output into wwwroot/admin automatically. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01Wi5qHAuq8UbzN4NLUFeKkJ
This commit is contained in:
@@ -231,6 +231,8 @@ export const routeTree = rootRoute.addChildren([
|
||||
export const router = createRouter({
|
||||
routeTree,
|
||||
defaultPreload: 'intent',
|
||||
// Matches vite.config.ts's `base`: '/admin/' in production builds, '/' in dev.
|
||||
basepath: import.meta.env.BASE_URL,
|
||||
context: { auth: undefined as unknown as AuthContextValue },
|
||||
});
|
||||
|
||||
|
||||
@@ -5,7 +5,9 @@ import react from '@vitejs/plugin-react';
|
||||
import tailwindcss from '@tailwindcss/vite';
|
||||
|
||||
// https://vite.dev/config/
|
||||
export default defineConfig({
|
||||
export default defineConfig(({ command }) => ({
|
||||
// Production builds are deployed under /admin (see Program.cs); the dev server keeps serving from '/'.
|
||||
base: command === 'build' ? '/admin/' : '/',
|
||||
plugins: [react(), tailwindcss()],
|
||||
resolve: {
|
||||
alias: {
|
||||
@@ -34,4 +36,4 @@ export default defineConfig({
|
||||
],
|
||||
},
|
||||
},
|
||||
});
|
||||
}));
|
||||
|
||||
Reference in New Issue
Block a user