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 assetPrefix not working in "standalone" build, because of serialization #65807

Open
lionskape opened this issue May 15, 2024 · 0 comments
Labels
bug Issue was opened via the bug report template. Output (export/standalone) Related to the the output option in `next.config.js`. Runtime Related to Node.js or Edge Runtime with Next.js.

Comments

@lionskape
Copy link

lionskape commented May 15, 2024

Link to the code that reproduces this issue

https://github.com/lionskape/next-standalone-assetprefix-bugrepot/blob/main/next.config.js

To Reproduce

  1. create next config like this:
let nextConfig = {
    output: 'standalone',
    assetPrefix: process.env.CDN_URI ?? '',
};
  1. run next build without CDN_URI variable
  2. run nextjs server CDN_URI="https://cdn.net" node .next/standalone/server.js

Current vs. Expected behavior

Current behavior:
No prefix will be added to resources because of config serialization -

const nextConfig = ${JSON.stringify(nextConfig)}

Expected behavior:
dynamic assetPrefix works fine, environment variable is consumed.

Provide environment information

Operating System:
  Platform: darwin
  Arch: arm64
  Version: Darwin Kernel Version 23.4.0: Fri Mar 15 00:10:42 PDT 2024; root:xnu-10063.101.17~1/RELEASE_ARM64_T6000
  Available memory (MB): 16384
  Available CPU cores: 10
Binaries:
  Node: 18.17.1
  npm: 9.6.7
  Yarn: N/A
  pnpm: 7.32.1
Relevant Packages:
  next: 14.2.3 // Latest available version is detected (14.2.3).
  eslint-config-next: N/A
  react: 18.2.0
  react-dom: 18.2.0
  typescript: 5.3.3
Next.js Config:
  output: standalone

Which area(s) are affected? (Select all that apply)

Output (export/standalone), Runtime

Which stage(s) are affected? (Select all that apply)

next build (local)

Additional context

No response

@lionskape lionskape added the bug Issue was opened via the bug report template. label May 15, 2024
@github-actions github-actions bot added Output (export/standalone) Related to the the output option in `next.config.js`. Runtime Related to Node.js or Edge Runtime with Next.js. labels May 15, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Issue was opened via the bug report template. Output (export/standalone) Related to the the output option in `next.config.js`. Runtime Related to Node.js or Edge Runtime with Next.js.
Projects
None yet
Development

No branches or pull requests

1 participant