0
0
Nginxdevops~10 mins

CORS configuration in Nginx - Interactive Code Practice

Choose your learning style9 modes available
Practice - 5 Tasks
Answer the questions below
1fill in blank
easy

Complete 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'
A"https://example.com"
B"localhost"
C"*"
D"null"
Attempts:
3 left
💡 Hint
Common Mistakes
Using a specific domain instead of wildcard
Missing quotes around the value
2fill in blank
medium

Complete 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'
A"OPTIONS"
B"GET, POST"
C"PUT, PATCH"
D"GET, POST, DELETE"
Attempts:
3 left
💡 Hint
Common Mistakes
Including methods not allowed
Missing quotes around the methods
3fill in blank
hard

Fix 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'
A"true"
Btrue
Cyes
D"yes"
Attempts:
3 left
💡 Hint
Common Mistakes
Using unquoted true
Using yes instead of true
4fill in blank
hard

Fill 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'
A"Content-Type, Authorization"
B"X-Custom-Header"
C"GET, POST, OPTIONS"
D"DELETE, PUT"
Attempts:
3 left
💡 Hint
Common Mistakes
Mixing headers and methods
Missing quotes around values
5fill in blank
hard

Fill 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'
A"https://mydomain.com"
B"GET, POST, OPTIONS"
C"Content-Type, Authorization"
D"*"
Attempts:
3 left
💡 Hint
Common Mistakes
Using wildcard for origin when specific domain is needed
Mixing headers and methods