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
unstable_revalidate
throws in production mode locally
#34874
Comments
Temp workaround was forcing next to bind to localhost:
|
I created the following reproduction:
import { useRouter } from "next/router"
export default function Home(props) {
const { query: { page } } = useRouter()
return (
<button
onClick={async () => {
await fetch(`/api/revalidate?page=${page}`)
window.location.reload()
}}
>
Revalidated {page}: {props.time}
</button>
)
}
export function getStaticPaths() {
return { paths: [], fallback: true }
}
export function getStaticProps() {
return { props: { time: new Date().toISOString() }, revalidate: 3600 }
}
export default async function handler(req, res) {
await res.unstable_revalidate(`/${req.query.page}`)
return res.json({ revalidated: true })
} And calling |
re-opening as this sounds like a bug with the host value we are using internally on some setups |
Ended up here because of a similar error but in my case the error message is a 404 (I went in and added the for path part)
The 404 for this path makes sense because it really should have a subdomain (e.g. http://chris.localhost:3000/posts/my-first-post). Digging further into this async function unstable_revalidate(urlPath, req, context) {
...
const baseUrl = context.trustHostHeader ? `https://${req.headers.host}` : `http://${context.hostname}:${context.port}`;
...
} If |
Closing as this should be fixed in the latest version of Next.js |
awesome thx :) ❤️ |
This closed issue has been automatically locked because it had no new activity for a month. If you are running into a similar issue, please create a new issue with the steps to reproduce. Thank you. |
Verify canary release
Provide environment information
What browser are you using? (if relevant)
No response
How are you deploying your application? (if relevant)
No response
Describe the Bug
Was able to figure out that the client could not request itself, perhaps because it's not bound to 0.0.0.0? But the error message was extremely poor and I had to edit the console.log in the following file to figure out what had happened
Expected Behavior
No error
To Reproduce
Build a Next.js app that has a dynamic statically rendered route with ISR, build it locally and run it locally and call unstable_revalidate to see it error.
The text was updated successfully, but these errors were encountered: