Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feat/render deployment #360

Merged
merged 3 commits into from
Sep 25, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 11 additions & 2 deletions Backend/src/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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<string>('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<number>('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();
1 change: 1 addition & 0 deletions Frontend/src/app/app.routes.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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 },
Expand Down
6 changes: 6 additions & 0 deletions Frontend/static.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"root": "dist/frontend",
"routes": {
"/**": "index.html"
}
}
Loading