getting a stale request sometimes

Filbert
Filbert Member Posts: 8

so i have used cloudinary for a while now but now i have gotten error like stale request. Do anyone know how to solve this problem ? i am using nextjs

Tagged:

Comments

  • Vdeub
    Vdeub Member, Cloudinary Staff Posts: 78

    Hi @Filbert,

    We have an article in our knowledge base here that explains the different reasons why you could get a stale request.

    Would you mind having a look at it? Looking at our logs, I can see the timestamp 1723788454 is sent which is Friday, 16 August 2024 06:07:34 and this request while the actual API call is done at August 16th 2024, 09:55:13 hence the error.

    Hope that helps.

    Best,

    Loic

  • Filbert
    Filbert Member Posts: 8

    Hello, yes i knew about that.
    but i have made using that suggestions which is like the code below. I dont get it how is that possible because when we want to upload, we always call this signature right away. So, it doesnt make sense if something like this will happen. Also, this is an error that comes sometimes. Can you help me to look at it ? Thanks

    export async function GET(): Promise<NextResponse> {  try {    const timestamp = Math.round(new Date().getTime() / 1000);    const params_to_sign = { timestamp };
        const signature = cloudinary.utils.api_sign_request(      params_to_sign,      apiSecret    );    console.log("timestamp: ", timestamp);    return NextResponse.json({ signature, timestamp }, { status: 200 });  } catch (error) {    console.error('Error generating signature:', error);    return NextResponse.json({ error: "Internal Server Error" }, { status: 500 });  }}

  • Vdeub
    Vdeub Member, Cloudinary Staff Posts: 78

    Hi @Filbert,

    As shared previously, you can see that the timestamp is off by more than 1 hour.

    Please try to reproduce and log the timestamp value you generate and the one you pass to the upload.

    Best,

    Loic