QuizzesCORS Configuration — Concept Check
intermediate
spring-boot

CORS Configuration — Concept Check

Questions on CORS Configuration. Cross-Origin Resource Sharing is configured globally via WebMvcConfigurer or per-controller with @CrossOrigin to control which origins browsers allow.

8 minutes 8 questions Pass at 70%
Time Limit
8 minutes - timer starts when you begin
Change Answers Freely
Revisit and change any answer before submitting
Full Review After Submit
Correct answers and explanations shown for every question
Auto-submit on timeout
Quiz submits automatically when time runs out

Questions in this quiz

8 questions on CORS Configuration — Concept Check. Work through them here, then start the quiz to answer them and see your score.

  1. 1.A frontend application hosted on app.example.com is trying to access an API on api.example.com, but the browser blocks the request. What could be a reason?

    • ACORS headers are not configured to allow app.example.com.
    • BThe API does not support HTTPS connections.
    • CThe API server is down.
    • DThe frontend application has a syntax error in its JavaScript.
  2. 2.In a Spring Boot application using Spring Security, where should you configure CORS to ensure it functions correctly?

    • AIn a CorsFilter bean only.
    • BIn the WebMvcConfigurer only.
    • CIn the application.properties file.
    • DIn the SecurityFilterChain configuration.
  3. 3.A developer sets allowedOrigins("*") with allowCredentials(true) in a CORS configuration. What is the outcome?

    • AThe configuration will work but is insecure.
    • BAll origins can send credentialed requests successfully.
    • CBrowsers will reject the configuration due to security risks.
    • DOnly specified origins can send credentialed requests.
  4. 4.Which method allows you to configure CORS globally in a Spring Boot application?

    • AImplementing WebMvcConfigurer and overriding addCorsMappings.
    • BSetting properties in application.properties.
    • CCreating a CorsFilter bean.
    • DUsing @CrossOrigin on each controller.
  5. 5.A public endpoint in a Spring Boot application needs to allow all origins without credentials. How should it be configured?

    • AUse @CrossOrigin(origins="*") with allowCredentials(true).
    • BUse registry.addMapping("/public/**").allowedOrigins("*").allowCredentials(false).
    • CSet allowedOrigins("*") in WebMvcConfigurer with allowCredentials(true).
    • DConfigure in SecurityFilterChain with allowCredentials(true).
  6. 6.A developer believes setting allowedHeaders("*") in CORS configuration is insecure. Is this true?

    • AYes, it allows malicious headers to be sent.
    • BNo, it only affects which headers are exposed, not security.
    • CNo, it allows any headers but doesn't pose a security risk by itself.
    • DYes, it exposes sensitive headers to all origins.
  7. 7.What happens if CORS is misconfigured with wildcard origins and credentials in a Spring Boot API?

    • AAll requests will be accepted, compromising security.
    • BRequests will be silently ignored by the server.
    • CThe browser will reject requests due to security policy violations.
    • DThe server will throw a runtime exception.
  8. 8.A developer uses @CrossOrigin on a controller to allow a third-party origin. What is a potential risk?

    • AThe global CORS configuration will be overridden completely.
    • BThe third-party origin might gain unintended access to sensitive data.
    • CThe application will become slower due to additional checks.
    • DThe controller will not be accessible at all.