Skip to content

Add support for regex in allowed origins for the CORS filter.#13778

Open
alexdupre wants to merge 1 commit into
playframework:mainfrom
alexdupre:cors-regex
Open

Add support for regex in allowed origins for the CORS filter.#13778
alexdupre wants to merge 1 commit into
playframework:mainfrom
alexdupre:cors-regex

Conversation

@alexdupre

Copy link
Copy Markdown
Contributor

Pull Request Checklist

Helpful things

Purpose

This PR adds the ability to use regular expressions when defining the allowed origins for the CORS filter.

Background Context

Sometimes explicitely declaring all allowed origins is not possible, for example when dynamic hostnames under the same domain are used. Currently the only option is to allow any origin, but this is sub-optimal. I've evaluated two different approaches to solve the issue:

  1. add support for wildcards (simpler, but still limited)
  2. add support for regular expressions (more complex, but more flexible)

Considering that other common web frameworks (like Node Express) already support regular expressions, I've opted for the second solution.

The change has been done in a full backward compatible way, so the CORS behavior is unchanged unless the new allowedOriginsAsRegex config parameter is set to true.

@mkurz

mkurz commented Apr 29, 2026

Copy link
Copy Markdown
Member

@Mergifyio rebase

@mergify

mergify Bot commented Apr 29, 2026

Copy link
Copy Markdown
Contributor

Deprecation notice: This pull request comes from a fork and was rebased using bot_account impersonation. This capability will be removed on July 1, 2026. After this date, the rebase action will no longer be able to rebase fork pull requests with this configuration. Please switch to the update action/command to ensure compatibility going forward.

@mergify

mergify Bot commented Apr 29, 2026

Copy link
Copy Markdown
Contributor

rebase

✅ Branch has been successfully rebased

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.

2 participants