jeremyevans / rodauth

Ruby's Most Advanced Authentication Framework
http://rodauth.jeremyevans.net
MIT License
1.67k stars 95 forks source link

JWT CORS: Mixing Strings and RexExp's in Array #249

Closed benoror closed 2 years ago

benoror commented 2 years ago

Hey! I have a particular scenario while using a provider such as Vercel which generates "Preview" deployments with random hashes inside the URL. Therefore I need to add a RegExp to jwt_cors_allow_origin, additionally to existing Strings, but I get the following error:

NoMethodError (undefined method `length' for /https:\/\/spoint-.*-benoror.vercel.app/:Regexp):

I am assuming the Array only accepts Strings, not RexExp's. Any workaround would be greatly appreciated!

jeremyevans commented 2 years ago

jwt_cors_allow_origin does not support an array containing regexps. You can use an array of strings, or a single regexp. Maybe you want jwt_cors_allow_origin Regexp.union(array_of_strings_and_or_regexps)?

benoror commented 2 years ago

Good idea! Gonna give it a shot!

And besides that, quickest issue reply ever, thanks! appreciate your work!

benoror commented 2 years ago

Regexp.union worked beautifully as a drop-in. Thanks again!