Friday 26 July 2019

Enable cors angular

https://www.techiediaries.com/angular-file-upload-progress-bar/


Enable CORS

Since we'll be using Angular served from a different port we'll need to enable CORS in our server.
Open the src/main.ts file and call the app.enableCors() method:
import { NestFactory } from '@nestjs/core';
import { AppModule } from './app.module';

async function bootstrap() {
  const app = await NestFactory.create(AppModule);
  app.enableCors();
  await app.listen(3000);
}
bootstrap();
You can now send Cross Origin Request from your Angular app to your Nest.js without any problems. In production, you may want to disable CORS

No comments:

Post a Comment

40 Latest Interview Questions and Answers on Spring, Spring MVC, and Spring Boot

  40 Latest Interview Questions and Answers on Spring, Spring MVC, and Spring Boot 1. What is Tight Coupling? When a class (ClassA) is depen...