The content in my Nextjs app is not updating after deployment

52 Views Asked by At
 The content in my Nextjs app is not updating after deployment. 
its being deployed as static in Vercel. 
but when I try locally it works absolutely fine. 
However it show the new content or updating 
after the re-deployment.[deploying as static](https://i.stack.imgur.com/trWjv.jpg) 
How to fix it?

import Connect from "../../../dbConfig/connect";
import { NextResponse } from "next/server";
const mongoose = require('mongoose')
import Post from "../../../models/postSchema";


Connect()

export async function GET(req, res){
    try{
        const posts = await Post.find()
        if(posts){
            
            const response = NextResponse.json(posts)
            return response
        }else{
            const response = NextResponse.json({
                message: `requested data cannot be obtained. The Database is empty`
            })
            return response
        }
    }catch(e){
        const response = NextResponse.json({
            message: `Internal server error - ${e}`
        })
        return response
    }
}



it's not getting updated data after deployment. gets only the previous data, until redeployment. this data is captured using a useEffect hook to show in the app.


useEffect(()=>{
        axios.get('/api/data').then(({data})=>{
            setData(data)           
        })
    },[])


but the view of app that came after the deployment not contain newly uploaded data after.

0

There are 0 best solutions below