Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

fix: issue on building inside docker image without .env (moved envs from default value at params) #5

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

Closed
Fiser12 wants to merge 1 commit into CrawlerCode:main from Fiser12:main

Conversation

@Fiser12
Copy link

@Fiser12 Fiser12 commented Nov 1, 2024
edited
Loading

Hi sir

This error only happends when you try to build the code without all the .env variable, for example, inside docker image could happen. The best way to avoid it is to not setting a process.env as a default param.

I make some tests and this will fix the issue. It only happends if you load this code from node modules package. This issue happends to me inside docker build only, but the solution is as easy as it.

36.94 server:build: Generating static pages (0/10) ... 37.77 server:build: Error occurred prerendering page "/". Read more: https://nextjs.org/docs/messages/prerender-error **37.77 server:build: Error: getPayloadUser requires a server URL to be provided, either as an option or in the 'NEXT_PUBLIC_SERVER_URL' environment variable** 37.77 server:build: at d (/app/apps/server/.next/server/chunks/3853.js:604:229796) 37.77 server:build: at f (/app/apps/server/.next/server/chunks/2196.js:1:6719) 37.77 server:build: at ek (/app/node_modules/.pnpm/next@15.0.1_@opentelemetry+api@1.9.0_@playwright+test@1.48.0_babel-plugin-react-compiler@0.0._rsqjemyostbi4mzxu4v37fu6p4/node_modules/next/dist/compiled/next-server/app-page.runtime.prod.js:84:13409) 37.77 server:build: at e (/app/node_modules/.pnpm/next@15.0.1_@opentelemetry+api@1.9.0_@playwright+test@1.48.0_babel-plugin-react-compiler@0.0._rsqjemyostbi4mzxu4v37fu6p4/node_modules/next/dist/compiled/next-server/app-page.runtime.prod.js:84:17307) 37.77 server:build: at eO (/app/node_modules/.pnpm/next@15.0.1_@opentelemetry+api@1.9.0_@playwright+test@1.48.0_babel-plugin-react-compiler@0.0._rsqjemyostbi4mzxu4v37fu6p4/node_modules/next/dist/compiled/next-server/app-page.runtime.prod.js:84:17769) 37.77 server:build: at Array.toJSON (/app/node_modules/.pnpm/next@15.0.1_@opentelemetry+api@1.9.0_@playwright+test@1.48.0_babel-plugin-react-compiler@0.0._rsqjemyostbi4mzxu4v37fu6p4/node_modules/next/dist/compiled/next-server/app-page.runtime.prod.js:84:14915) 37.77 server:build: at stringify (<anonymous>) 37.77 server:build: at eU (/app/node_modules/.pnpm/next@15.0.1_@opentelemetry+api@1.9.0_@playwright+test@1.48.0_babel-plugin-react-compiler@0.0._rsqjemyostbi4mzxu4v37fu6p4/node_modules/next/dist/compiled/next-server/app-page.runtime.prod.js:84:26272) 37.77 server:build: at eq (/app/node_modules/.pnpm/next@15.0.1_@opentelemetry+api@1.9.0_@playwright+test@1.48.0_babel-plugin-react-compiler@0.0._rsqjemyostbi4mzxu4v37fu6p4/node_modules/next/dist/compiled/next-server/app-page.runtime.prod.js:84:26502) 37.77 server:build: at eB (/app/node_modules/.pnpm/next@15.0.1_@opentelemetry+api@1.9.0_@playwright+test@1.48.0_babel-plugin-react-compiler@0.0._rsqjemyostbi4mzxu4v37fu6p4/node_modules/next/dist/compiled/next-server/app-page.runtime.prod.js:84:27056) 37.77 server:build: Export encountered an error on /(web)/page: /, exiting the build. 37.78 server:build: ⨯ Static worker exited with code: 1 and signal: null 37.87 server:build: ELIFECYCLE Command failed with exit code 1. 37.88 server:build: ERROR: command finished with error: command (/app/apps/server) /usr/local/bin/pnpm run build exited (1) 37.88 server#build: command (/app/apps/server) /usr/local/bin/pnpm run build exited (1)

Copy link
Owner

I have also tried it by myself and this error occurs when nextjs try to prerender the page at buildtime.
The main cause is that Next.js is trying to discover if this route is dynamic and this error is thrown before the Dynamic API cookies is used.

The solution for this error is quite simple, the error musst be thrown after the cookies statement. So Next.js will no longer try to render this page static.

Copy link
Owner

@CrawlerCode CrawlerCode left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

By the way:
Your change should not actually have any effect. serverUrl remains undefined

Copy link
Author

Fiser12 commented Nov 4, 2024

It's a strange error what happened to me but this small change fixed it, I duplicated the function in my project to fix it. Consider it if somebody more has that error.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Reviewers

@CrawlerCode CrawlerCode CrawlerCode left review comments

Assignees

No one assigned

Labels

None yet

Projects

None yet

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

AltStyle によって変換されたページ (->オリジナル) /