Skip to content
This repository was archived by the owner on Jan 28, 2025. It is now read-only.
This repository was archived by the owner on Jan 28, 2025. It is now read-only.

getInitialProps is cached, not updated. #268

@kyun

Description

@kyun

Describe the bug
I am getting some data from my DB in getInitialProps.
When I changed my DB data, getInitialProps didn't catch the changed data.

To Reproduce

MyPage.getInitialProps = async (props) => {
  try{
    const { data } = await axios.get('MY_API_URL').catch((e)=>{ throw e });
    if(data.isPublished) return { data };
    else throw data;
  }catch(e){
    return { ...e }
  }
}

This issue occurs in production.
This code is working even I changed isPublished to false.
I mean,

At the first, I set up the isPublished to false.
I entered the Web, I can see Error Page.

and then, I changed the isPublished to true.
I entered the Web, I can see MyPage.

and, I changed again to false the isPublished.
I entered the Web, I can still see MyPage.

Expected behavior
I want to remove the cached data in getInitialProps

What I am missing?

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions