Practice - 5 Tasks
Answer the questions below
1fill in blank
easyComplete the code to allow all origins in CORS.
Nginx
add_header Access-Control-Allow-Origin [1]; Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Using a specific domain instead of wildcard
Missing quotes around the value
✗ Incorrect
The wildcard "*" allows all origins to access the resource.
2fill in blank
mediumComplete the code to allow only GET and POST methods in CORS.
Nginx
add_header Access-Control-Allow-Methods [1]; Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Including methods not allowed
Missing quotes around the methods
✗ Incorrect
Only GET and POST methods are allowed by specifying them as a comma-separated string.
3fill in blank
hardFix the error in the code to allow credentials in CORS.
Nginx
add_header Access-Control-Allow-Credentials [1]; Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Using unquoted true
Using yes instead of true
✗ Incorrect
The value must be the string "true" with quotes to enable credentials.
4fill in blank
hardFill both blanks to allow headers and methods in CORS.
Nginx
add_header Access-Control-Allow-Headers [1]; add_header Access-Control-Allow-Methods [2];
Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Mixing headers and methods
Missing quotes around values
✗ Incorrect
The first header allows common headers like Content-Type and Authorization.
The second header allows GET, POST, and OPTIONS methods.
5fill in blank
hardFill all three blanks to configure CORS for origin, methods, and headers.
Nginx
add_header Access-Control-Allow-Origin [1]; add_header Access-Control-Allow-Methods [2]; add_header Access-Control-Allow-Headers [3];
Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Using wildcard for origin when specific domain is needed
Mixing headers and methods
✗ Incorrect
This configuration allows only the specified origin, common HTTP methods, and common headers.