Can `headers` from `next/headers` be called multiple times safely?
Unanswered
Bombay posted this in #help-forum
BombayOP
By safely, I mean being sure that it isn't an operation that can cause performance issues later on, imposing a refactor.
An example of what I'm meaning (in a route handler):
I'm asking this because I'd choose this approach over sending a parameter every time.
An example of what I'm meaning (in a route handler):
import { headers } from 'next/headers';
const someFunction = () => {
// ...
const reqHeaders = headers();
// ...
}
export const GET = async () =>{
// ...
const reqHeaders = headers();
// ...
someFunction();
// ...
} I'm asking this because I'd choose this approach over sending a parameter every time.