Complete the code to enable CORS in a NestJS application.
const app = await NestFactory.create(AppModule); app.[1](); await app.listen(3000);
In NestJS, enableCors() is the method to enable CORS support on the app instance.
Complete the code to allow CORS only from 'https://example.com'.
const app = await NestFactory.create(AppModule);
app.enableCors({ origin: [1] });
await app.listen(3000);Setting origin to 'https://example.com' restricts CORS to that domain only.
Fix the error in this CORS configuration to allow credentials.
app.enableCors({ origin: 'https://example.com', [1]: true });The correct option to allow credentials in NestJS CORS config is credentials.
Fill both blanks to configure CORS to accept GET and POST methods from any origin.
app.enableCors({ origin: [1], methods: [2] });Using '*' for origin allows all origins. Setting methods to ['GET', 'POST'] restricts allowed HTTP methods.
Fill all three blanks to configure CORS with origin 'https://app.com', allow credentials, and only allow PUT method.
app.enableCors({ origin: [1], credentials: [2], methods: [3] });This configuration restricts CORS to 'https://app.com', allows credentials, and only permits PUT requests.