-
Notifications
You must be signed in to change notification settings - Fork 34
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
Dynamic Code Evaluation prevents Flagsmith to run on Next.js middlewares #112
Comments
@dabeeeenster all of the flagsmith code is obfuscated and compiled. you don't provide unobfuscated source. you've added the |
Hi @alizain - i don't follow - the source is in this repo? |
my bad, i couldn't find the correct file :) |
Hey @cagrispan, this wasn't on my radar but I'd like to help with this - am a massive fan of Next.js. It might actually be worth trying with the latest version >3, calls to async storage now check for typeof window, e.g https://github.com/Flagsmith/flagsmith-js-client/blob/main/flagsmith-core.ts#L270 |
This is now available in flagsmith 3.3.2, there's a working example here |
Nice @kyle-ssg! Thank you! |
No problem! I'd love to hear about what you do with it, had a play around with it today, It looks like the main use cases would be redirecting for abn tests maybe |
Precisely. Since it was not supported then, we are calling Flagsmith API to retrieve the flags and route based on that. And you are right, it's for ab tests. |
Hi,
I'm trying to run
flagsmith
on a Next.js middleware to load different routes depending on flags as below:It runs locally, but fails on build with the error:
I would like to know if there is a plan to support Next.js Middlewares in the near future.
For reference:
Edge Runtime Unsupported APIs
UPDATE
The
Function
calls are added whenAsyncStorage
is used. If you don't pass it as a parameter and build the project, it will not include any dynamic code evaluation on the index files.This is not a solution, just some progress on the investigation.
The text was updated successfully, but these errors were encountered: