diff --git a/backend/src/server.ts b/backend/src/server.ts index 485f21e..1e0097b 100644 --- a/backend/src/server.ts +++ b/backend/src/server.ts @@ -18,10 +18,10 @@ import { roomRouter } from './routes/index.js'; import { - indexHtmlPath, + frontendDirectoryPath, + frontendHtmlPath, internalApiHtmlFilePath, publicApiHtmlFilePath, - publicFilesPath, webcomponentBundlePath } from './utils/path-utils.js'; @@ -39,7 +39,7 @@ const createApp = () => { } // Serve static files - app.use(express.static(publicFilesPath)); + app.use(express.static(frontendDirectoryPath)); app.use(express.json()); app.use(jsonSyntaxErrorHandler); app.use(cookieParser()); @@ -69,7 +69,7 @@ const createApp = () => { // Serve OpenVidu Meet webcomponent bundle file app.get('/meet/v1/openvidu-meet.js', (_req: Request, res: Response) => res.sendFile(webcomponentBundlePath)); // Serve OpenVidu Meet index.html file for all non-API routes - app.get(/^(?!.*\/(api|internal-api)\/).*$/, (_req: Request, res: Response) => res.sendFile(indexHtmlPath)); + app.get(/^(?!.*\/(api|internal-api)\/).*$/, (_req: Request, res: Response) => res.sendFile(frontendHtmlPath)); // Catch all other routes and return 404 app.use((_req: Request, res: Response) => res.status(404).json({ error: 'Path Not Found', message: 'API path not implemented' }) diff --git a/backend/src/utils/path-utils.ts b/backend/src/utils/path-utils.ts index 071fcad..5e290a2 100644 --- a/backend/src/utils/path-utils.ts +++ b/backend/src/utils/path-utils.ts @@ -73,17 +73,21 @@ const currentDir = getCurrentDir(); const projectRoot = getProjectRoot(isDev, currentDir); // Export the paths for public files and webcomponent bundle -export const publicFilesPath = path.join(projectRoot, 'public'); -export const webcomponentBundlePath = path.join(publicFilesPath, 'webcomponent/openvidu-meet.bundle.min.js'); -export const indexHtmlPath = path.join(publicFilesPath, 'index.html'); -export const publicApiHtmlFilePath = path.join(publicFilesPath, 'openapi', 'public.html'); -export const internalApiHtmlFilePath = path.join(publicFilesPath, 'openapi', 'internal.html'); +export const publicDirectoryPath = path.join(projectRoot, 'public'); +export const frontendDirectoryPath = path.join(publicDirectoryPath, 'frontend'); +const webcomponentDirectoryPath = path.join(publicDirectoryPath, 'webcomponent'); +const openApiDirectoryPath = path.join(publicDirectoryPath, 'openapi'); + +export const webcomponentBundlePath = path.join(webcomponentDirectoryPath, 'openvidu-meet.bundle.min.js'); +export const frontendHtmlPath = path.join(frontendDirectoryPath, 'index.html'); +export const publicApiHtmlFilePath = path.join(openApiDirectoryPath, 'public.html'); +export const internalApiHtmlFilePath = path.join(openApiDirectoryPath, 'internal.html'); // Verify the existence of the paths console.log('[PATH-UTILS] Project root resolved to:', projectRoot); -verifyPathExists(publicFilesPath, 'Public files directory'); +verifyPathExists(publicDirectoryPath, 'Public files directory'); verifyPathExists(webcomponentBundlePath, 'Webcomponent bundle'); -verifyPathExists(indexHtmlPath, 'Index HTML file'); +verifyPathExists(frontendHtmlPath, 'Index HTML file'); verifyPathExists(publicApiHtmlFilePath, 'Public API documentation'); verifyPathExists(internalApiHtmlFilePath, 'Internal API documentation'); console.log('---------------------------------------------------------'); diff --git a/frontend/angular.json b/frontend/angular.json index ce41746..055b887 100644 --- a/frontend/angular.json +++ b/frontend/angular.json @@ -43,7 +43,7 @@ }, "production": { "outputPath": { - "base": "../backend/public", + "base": "../backend/public/frontend", "browser": "" }, "deleteOutputPath": true,