Skip to content
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 (e. g. 'eval', 'new Function') not allowed in Middleware pages/_middleware even if my middleware is quite simple #32532

Closed
vadimsabadosh opened this issue Dec 15, 2021 · 3 comments
Labels
bug Issue was opened via the bug report template.

Comments

@vadimsabadosh
Copy link

What version of Next.js are you using?

12.0.7

What version of Node.js are you using?

v14.16.1

What browser are you using?

Google Chrome 96.0.4664.93

What operating system are you using?

Windows

How are you deploying your application?

next start

Describe the Bug

I have this code in _middleware.ts to check URL validation using graphql.
image

Whenever I use "next start" it works fine, but whenever I use "next build" I get the error:
Dynamic Code Evaluation (e. g. 'eval', 'new Function') not allowed in Middleware pages/_middleware

Expected Behavior

I want to use graphql requests in middleware. What do I need to change?

To Reproduce

  1. Create a project with graphql
  2. Create middleware.ts with graphql request and put variables into a request.
  3. Run "npm run build" or "next build"
  4. Get an error
@vadimsabadosh vadimsabadosh added the bug Issue was opened via the bug report template. label Dec 15, 2021
@balazsorban44
Copy link
Member

Duplicate of #31694

@balazsorban44 balazsorban44 marked this as a duplicate of #31694 Dec 15, 2021
@vadimsabadosh
Copy link
Author

vadimsabadosh commented Dec 17, 2021

Duplicate of #31694

I'm not sure about duplicate

Researching the bug better I discovered that
I'm still having the issue even if I don't use anything in the middleware

image
image

@vadimsabadosh vadimsabadosh changed the title Dynamic Code Evaluation (e. g. 'eval', 'new Function') not allowed in Middleware pages/_middleware with apollo graphql Dynamic Code Evaluation (e. g. 'eval', 'new Function') not allowed in Middleware pages/_middleware even if my middleware is quite simple Dec 17, 2021
@balazsorban44
Copy link
Member

This issue has been automatically locked due to no recent activity. If you are running into a similar issue, please create a new issue with the steps to reproduce. Thank you.

@vercel vercel locked as resolved and limited conversation to collaborators Jan 27, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
bug Issue was opened via the bug report template.
Projects
None yet
Development

No branches or pull requests

2 participants