Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[sitecore-jss-nextjs][sitecore-jss] multi-origin CORS validation for next editing middlewares #1798

Merged
merged 6 commits into from
May 20, 2024

Conversation

art-alexeyenko
Copy link
Contributor

@art-alexeyenko art-alexeyenko commented May 19, 2024

Description / Motivation

CORS configuration through next config only allows to set a single allowed origin - or a wildcard.
JSS editing API endpoints require a more sophisticated configuration. This PR adds a function to validate incoming origin against multiple possible values, with an option to configure more allowed origins through env variable.
It also applies this CORS validation function to editing middleware handlers:

  • ensures handler stops execution when incoming request's origin does not match allowed origins list
  • Sitecore Pages' hostnames are tested against by default

Testing Details

  • Unit Test Added
  • Manual Test/Other (Please elaborate)

Types of changes

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to change)

@art-alexeyenko art-alexeyenko requested a review from a team May 19, 2024 22:47
Copy link
Contributor

@illiakovalenko illiakovalenko left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks nice! See some comments below
Please, update the CHANGELOG as well

Copy link
Contributor

@illiakovalenko illiakovalenko left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks great 👍

Copy link
Contributor

@yavorsk yavorsk left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nice!

@art-alexeyenko art-alexeyenko merged commit 1a8ceb5 into dev May 20, 2024
1 check passed
@art-alexeyenko art-alexeyenko deleted the bug/jss-1872-editing-config-api-cors branch May 20, 2024 15:27
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants