From af0dcbcc0775415d75d4ed28982b05f32a966fcb Mon Sep 17 00:00:00 2001 From: 21797545 Date: Wed, 25 Sep 2024 08:41:39 +0200 Subject: [PATCH 1/3] =?UTF-8?q?=F0=9F=9A=A7Added=20config=20for=20render?= =?UTF-8?q?=20deployment?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Backend/src/main.ts | 13 +++++++++++-- Frontend/static.json | 5 +++++ 2 files changed, 16 insertions(+), 2 deletions(-) create mode 100644 Frontend/static.json 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/static.json b/Frontend/static.json new file mode 100644 index 00000000..5aad9fcb --- /dev/null +++ b/Frontend/static.json @@ -0,0 +1,5 @@ +{ + "routes": { + "/**": "index.html" + } +} From 1829345013dbcfa6bfff7c2da4a473da3847d3f7 Mon Sep 17 00:00:00 2001 From: 21797545 Date: Wed, 25 Sep 2024 08:50:46 +0200 Subject: [PATCH 2/3] =?UTF-8?q?=F0=9F=9A=A7Updated=20wildcard=20route?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Frontend/src/app/app.routes.ts | 1 + 1 file changed, 1 insertion(+) 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 }, From ab0f89d61f06301890d2fd4027def22977b2fdc9 Mon Sep 17 00:00:00 2001 From: 21797545 Date: Wed, 25 Sep 2024 09:09:34 +0200 Subject: [PATCH 3/3] :construction: Updated static.json --- Frontend/static.json | 1 + 1 file changed, 1 insertion(+) diff --git a/Frontend/static.json b/Frontend/static.json index 5aad9fcb..f5e91f8c 100644 --- a/Frontend/static.json +++ b/Frontend/static.json @@ -1,4 +1,5 @@ { + "root": "dist/frontend", "routes": { "/**": "index.html" }