-
-
Notifications
You must be signed in to change notification settings - Fork 872
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
Allow it to work on edge (e.g. cloudflare workers) #2318
Comments
Up ! |
Up! Also a question, is it possible to use ajv in web worker? |
I use this library https://github.com/cfworker/cfworker/tree/main/packages/json-schema alternative |
Thanks for the extra info @cosbgn. I have looked into it and I can only see that of the disallowed functions, AJV only uses So I am curious, can you use AJV in cloudflare if you avoid the
Otherwise I can only suggest prebuilding your validation functions in CI using
Then within your application code you can require the validation functions.
|
I think pre-compiling functions is a good option here so will close unless someone strongly disagrees. |
Currently AJV can't run on cloudflare workers, vercel-edge and other edge environments.
When trying to run it, the worker throws an error:
Most likely this is because they restrict certain JavaScript functions like
eval(), new Function(), setTimeout([string])
, andsetInterval([string])
, which can execute code generated from strings.I'm not sure why these functions are needed but it would be better to avoid them so that it could run everywhere without issues.
The text was updated successfully, but these errors were encountered: