vercel / next.js

The React Framework
https://nextjs.org
MIT License
126.83k stars 26.96k forks source link

Cache-Control should be set by default for pages and api routes #61013

Open fellmann opened 9 months ago

fellmann commented 9 months ago

Link to the code that reproduces this issue

https://codesandbox.io/p/devbox/lucid-haslett-2k2psv

To Reproduce

  1. Build the application: next build
  2. Start the application: next start

Current vs. Expected behavior

Current behavior: pages (/) and api (/api/test) do not respond with a Cache-Control header, resulting in random stale responses. Expected behavior: a default (maybe configurable) cache-control policy is used, like when deploying to Vercel - see https://vercel.com/docs/edge-network/headers#cache-control

Provide environment information

https://vercel.com/docs/edge-network/headers#cache-controlOperating System:
  Platform: linux
  Arch: x64
  Version: #1 SMP PREEMPT_DYNAMIC Sun Aug  6 20:05:33 UTC 2023
Binaries:
  Node: 20.9.0
  npm: 9.8.1
  Yarn: 1.22.19
  pnpm: 8.10.2
Relevant Packages:
  next: 14.1.1-canary.6 // Latest available version is detected (14.1.1-canary.6).
  eslint-config-next: N/A
  react: 18.2.0
  react-dom: 18.2.0
  typescript: 5.1.3
Next.js Config:
  output: N/A

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

Middleware / Edge (API routes, runtime)

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

next start (local)

Additional context

No response

harshilmadaliya commented 9 months ago

but deploy on varcel this was been occured error like this :

npm ERR! code ERESOLVE -- 19:46:52.116 | npm ERR! ERESOLVE could not resolve 19:46:52.117 | npm ERR! 19:46:52.117 | npm ERR! While resolving: next-auth@4.24.5 19:46:52.117 | npm ERR! Found: next@14.1.1-canary.6 19:46:52.117 | npm ERR! node_modules/next 19:46:52.118 | npm ERR! next@"^14.1.1-canary.6" from the root project 19:46:52.118 | npm ERR! 19:46:52.118 | npm ERR! Could not resolve dependency: 19:46:52.118 | npm ERR! peer next@"^12.2.5 \|\| ^13 \|\| ^14" from next-auth@4.24.5 19:46:52.118 | npm ERR! node_modules/next-auth 19:46:52.119 | npm ERR! next-auth@"^4.24.5" from the root project 19:46:52.119 | npm ERR! 19:46:52.119 | npm ERR! Conflicting peer dependency: next@14.1.0 19:46:52.119 | npm ERR! node_modules/next 19:46:52.119 | npm ERR! peer next@"^12.2.5 \|\| ^13 \|\| ^14" from next-auth@4.24.5 19:46:52.120 | npm ERR! node_modules/next-auth 19:46:52.120 | npm ERR! next-auth@"^4.24.5" from the root project 19:46:52.120 | npm ERR! 19:46:52.120 | npm ERR! Fix the upstream dependency conflict, or retry 19:46:52.120 | npm ERR! this command with --force or --legacy-peer-deps 19:46:52.120 | npm ERR! to accept an incorrect (and potentially broken) dependency resolution. 19:46:52.120 | npm ERR! 19:46:52.121 | npm ERR! 19:46:52.121 | npm ERR! For a full report see: 19:46:52.122 | npm ERR! /vercel/.npm/_logs/2024-01-23T14_16_50_716Z-eresolve-report.txt 19:46:52.122 |   19:46:52.122 | npm ERR! A complete log of this run can be found in: /vercel/.npm/_logs/2024-01-23T14_16_50_716Z-debug-0.log 19:46:52.134 | Error: Command "npm install" exited with 1