diff --git a/apps/server/src/app.service.ts b/apps/server/src/app.service.ts
index 2530ce6..568beae 100644
--- a/apps/server/src/app.service.ts
+++ b/apps/server/src/app.service.ts
@@ -5,10 +5,10 @@ import { ConfigService } from '@nestjs/config';
export class AppService {
constructor(private readonly configService: ConfigService) {}
getHello(): string {
+ const { host, isProd, port, baseUrl } = this.configService.get('server');
return `
- `;
+
+ `;
}
}
diff --git a/apps/server/src/configuration.ts b/apps/server/src/configuration.ts
index dd97159..ae5b783 100644
--- a/apps/server/src/configuration.ts
+++ b/apps/server/src/configuration.ts
@@ -2,6 +2,7 @@ const configuration = () => {
const isProd = process.env.NODE_ENV === 'production';
const port = process.env.PORT || 4000;
const host = process.env.HOST || '0.0.0.0';
+ const baseUrl = process.env.WEWERSS_BASE_URL || '/';
const maxRequestPerMinute = parseInt(
`${process.env.MAX_REQUEST_PER_MINUTE}|| 60`,
@@ -19,7 +20,7 @@ const configuration = () => {
const enableCleanHtml = process.env.ENABLE_CLEAN_HTML === 'true';
return {
- server: { isProd, port, host },
+ server: { isProd, port, host, baseUrl },
throttler: { maxRequestPerMinute },
auth: { code: authCode },
platform: { url: platformUrl },
diff --git a/apps/server/src/main.ts b/apps/server/src/main.ts
index 2095980..8502f88 100644
--- a/apps/server/src/main.ts
+++ b/apps/server/src/main.ts
@@ -19,14 +19,15 @@ async function bootstrap() {
const app = await NestFactory.create(AppModule);
const configService = app.get(ConfigService);
- const { host, isProd, port } =
+ const { host, isProd, port, baseUrl } =
configService.get('server')!;
-
+ const assetsPrefix = `${baseUrl}dash/assets/`;
+ app.setGlobalPrefix(baseUrl);
app.use(json({ limit: '10mb' }));
app.use(urlencoded({ extended: true, limit: '10mb' }));
app.useStaticAssets(join(__dirname, '..', 'client', 'assets'), {
- prefix: '/dash/assets/',
+ prefix: assetsPrefix,
});
app.setBaseViewsDir(join(__dirname, '..', 'client'));
app.setViewEngine('hbs');
diff --git a/apps/web/src/App.tsx b/apps/web/src/App.tsx
index d92ee12..08bb05e 100644
--- a/apps/web/src/App.tsx
+++ b/apps/web/src/App.tsx
@@ -8,7 +8,7 @@ import ThemeProvider from './provider/theme';
function App() {
return (
-
+
diff --git a/apps/web/src/provider/trpc.tsx b/apps/web/src/provider/trpc.tsx
index 673a434..a46c615 100644
--- a/apps/web/src/provider/trpc.tsx
+++ b/apps/web/src/provider/trpc.tsx
@@ -5,7 +5,7 @@ import { useState } from 'react';
import { toast } from 'sonner';
import { isTRPCClientError, trpc } from '../utils/trpc';
import { getAuthCode, setAuthCode } from '../utils/auth';
-import { enabledAuthCode, serverOriginUrl } from '../utils/env';
+import { enabledAuthCode, serverOriginUrl, baseUrl } from '../utils/env';
export const TrpcProvider: React.FC<{ children: React.ReactNode }> = ({
children,
@@ -81,7 +81,7 @@ export const TrpcProvider: React.FC<{ children: React.ReactNode }> = ({
enabled: () => true,
}),
httpBatchLink({
- url: serverOriginUrl + '/trpc',
+ url: serverOriginUrl + baseUrl + 'trpc',
async headers() {
const token = getAuthCode();
diff --git a/apps/web/src/utils/env.ts b/apps/web/src/utils/env.ts
index 19a5d0c..42d6f09 100644
--- a/apps/web/src/utils/env.ts
+++ b/apps/web/src/utils/env.ts
@@ -8,3 +8,5 @@ export const appVersion = __APP_VERSION__;
export const enabledAuthCode =
window.__WEWE_RSS_ENABLED_AUTH_CODE__ === false ? false : true;
+
+export const baseUrl = import.meta.env.VITE_WEWERSS_BASE_URL || '/';
diff --git a/apps/web/vite.config.ts b/apps/web/vite.config.ts
index afe8d16..8347e02 100644
--- a/apps/web/vite.config.ts
+++ b/apps/web/vite.config.ts
@@ -1,4 +1,4 @@
-import { defineConfig } from 'vite';
+import { defineConfig, loadEnv } from 'vite';
import react from '@vitejs/plugin-react';
import { resolve } from 'path';
import { readFileSync } from 'fs';
@@ -6,7 +6,7 @@ import { readFileSync } from 'fs';
const projectRootDir = resolve(__dirname);
const isProd = process.env.NODE_ENV === 'production';
-
+const baseUrl = loadEnv('mode', process.cwd()).VITE_WEWERSS_BASE_URL || '/';
console.log('process.env.NODE_ENV: ', process.env.NODE_ENV);
const packageJson = JSON.parse(
@@ -15,7 +15,7 @@ const packageJson = JSON.parse(
// https://vitejs.dev/config/
export default defineConfig({
- base: '/dash',
+ base: `${baseUrl}dash`,
define: {
__APP_VERSION__: JSON.stringify(packageJson.version),
},