Is it possible to use a regex pattern in check_origin of a websocket?

In Corsica I can use a regex pattern for my CORS list, but when checking the Phoenix.Channels documentation I don’t see any mention of this. It seems like you can use a wildcard for subdomains, but not a regex pattern. Am I out of luck, or is there a solution?

For reference, here is the regex pattern that I want to apply: /^https:\/\/myapp(-staging)?(--[a-zA-Z0-9-]+)?\.web\.app\/?$/

The :check_origin config accepts an mfa tuple:

      check_origin: {MyAppWeb.Auth, :my_check_origin?, []}

The MFA is invoked with the request %URI{} as the first argument, followed by arguments in the MFA list, and must return a boolean. So you can perfect your regex there as you wish :slight_smile:

4 Likes

Oh, I thought that MFA stood for Multi-factor authentication in this context, but it’s module, function, args :sweat_smile: