Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
NOTE: This PR is stacked on top of my logging PR, that will need to be merged first.
Description
Adds W3C standards compliant support for CORS for the BFF
How Has This Been Tested?
This can be tested by running the BFF in full mock mode as the headers are generated by a middleware that will run in all scenarios. The tests involve merely querying the health check endpoint with a different combination of headers.
This to note:
Scenario 1: Testing with CORS disabled
Start the server:
Run a curl against the health check endpoint:
Expected outcome: The endpoint should function as normal and there should be no CORS headers in the response.
Scenario 2: Test with a single allowed origin
Start the server:
2.1 Make a request with an allowed origin header
Expected outcome: Successful request with the following CORS specific headers:
2.2 Make a request with a disallowed origin header
Expected outcome: The request should be successful, but the only CORS header in the response should be:
If there are any other Access-Control-* headers present the test has failed!
2.3 Simulate a CORS pre-flight request for an allowed origin:
Expected outcome: A response like below - note the CORS headers.
2.4 Simulate a CORS pre-flight request for a disallowed origin
Expected outcome: A response like below - note the lack of CORS headers aside from the
Vary
headerAdditional tests:
You can repeat the above tests using an allow list of multiple origins, simply add comma separated ones to the make command e.g.
NOTE: Only a single origin is allowed in the
Access-Control-Allow-Origin
header, so the BFF will return only a single origin if theOrigin
request header matches the allow list.Also you can test that allowing all origins (wildcard) works as expected:
Merge criteria:
DCO
check)If you have UI changes