diff --git a/Backend/src/main.ts b/Backend/src/main.ts index 00b5150e..471f5541 100644 --- a/Backend/src/main.ts +++ b/Backend/src/main.ts @@ -3,20 +3,29 @@ import { AppModule } from './app.module'; import { ConfigService } from '@nestjs/config'; async function bootstrap() { + // Create Nest application const app = await NestFactory.create(AppModule); const configService = app.get(ConfigService); + // Enable CORS and configure origin from environment variable or default to localhost app.enableCors({ - origin: configService.get('CORS_ORIGIN', 'http://localhost:4200'), + origin: configService.get('CORS_ORIGIN', 'http://localhost:4200'), methods: "GET,HEAD,PUT,PATCH,POST,DELETE,OPTIONS", credentials: true, }); + // Set global prefix for API app.setGlobalPrefix('api'); - const port = configService.get('PORT', 3000); + // Use Render's assigned PORT environment variable, fallback to 3000 if not set + const port = configService.get('PORT', 3000); + + // Start the NestJS app await app.listen(port); + + // Log the application URL console.log(`Application is running on: ${await app.getUrl()}`); } +// Bootstrap the application bootstrap(); diff --git a/Frontend/src/app/app.routes.ts b/Frontend/src/app/app.routes.ts index 1f466148..2b8d0599 100644 --- a/Frontend/src/app/app.routes.ts +++ b/Frontend/src/app/app.routes.ts @@ -26,6 +26,7 @@ export const routes: Routes = [ { path: "mood", component: MoodComponent }, { path: "auth/callback", component: AuthCallbackComponent }, { path: "", redirectTo: "/login", pathMatch: "full" }, + { path: '**', redirectTo: '/login' }, { path: "settings", component: SettingsComponent }, { path: "artist-profile", component: ArtistProfileComponent }, { path: "help", component: HelpMenuComponent }, diff --git a/Frontend/static.json b/Frontend/static.json new file mode 100644 index 00000000..f5e91f8c --- /dev/null +++ b/Frontend/static.json @@ -0,0 +1,6 @@ +{ + "root": "dist/frontend", + "routes": { + "/**": "index.html" + } +}