-
Notifications
You must be signed in to change notification settings - Fork 2.4k
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
fix: Can no longer access header values sent through JSON helper via loaderHeaders.get #1705
fix: Can no longer access header values sent through JSON helper via loaderHeaders.get #1705
Conversation
* Add missing async keywords * Update contributors.yml
Hi @himorishige, Welcome, and thank you for contributing to Remix! Before we consider your pull request, we ask that you sign our Contributor License Agreement (CLA). We require this only once. You may review the CLA and sign it by adding your name to contributors.yml. Once the CLA is signed, the If you have already signed the CLA and received this response in error, or if you have any questions, please contact us at hello@remix.run. Thanks! - The Remix team |
Thank you for signing the Contributor License Agreement. Let's get this merged! 🥳 |
*Total -- 1,042.02kb -> 923.03kb (11.42%) /examples/turborepo-vercel/vercel-project-config-example.png -- 163.96kb -> 90.54kb (44.78%) /examples/image-resize/assets/dog-1.jpg -- 672.67kb -> 628.55kb (6.56%) /examples/image-resize/assets/other-dogs/dog-2.jpg -- 37.92kb -> 37.13kb (2.08%) /fixtures/gists-app/app/components/guitar.jpg -- 167.48kb -> 166.81kb (0.4%) Signed-off-by: ImgBotApp <ImgBotHelp@gmail.com> Co-authored-by: ImgBotApp <ImgBotHelp@gmail.com>
You mind writing a test for this? I'm unclear on how the bug surfaces, and why this fixes it. I'd expect the fix to be in the |
This reverts commit 04d52b8.
…ub.com:himorishige/remix into fix/cannot-access-loader-headers-header-values
Please see the comments on #1140 |
Thanks for reviewing it. I'm hoping that in my environment, the header will be no-store.
import { HeadersFunction, json, LoaderFunction } from 'remix';
export const headers: HeadersFunction = ({ loaderHeaders }) => {
console.log(loaderHeaders.get('Cache-Control')); // return null
const cacheControl =
loaderHeaders.get('Cache-Control') ??
'max-age=0, s-maxage=60, stale-while-revalidate=60';
return {
'Cache-Control': cacheControl,
};
};
export const loader: LoaderFunction = async () => {
return json(null, { headers: { 'Cache-Control': 'no-store' } });
};
export default function PostsId() {
return <div className="prose p-4">text</div>;
} https://codesandbox.io/s/intelligent-sammet-losgp?file=/app/routes/index.tsx |
Ah we have regression here, at the moment, |
Thank you. |
I modified the header values sent by the JSON helper to be accessible via loaderHeaders.get
close #1140