#Authorization header is invalid after CLI App released

1 messages · Page 1 of 1 (latest)

granite thunder
#

After releasing my CLI API I started getting "Couldn't extract the caller identity from the request. Authorization header is invalid" while currentCart.getCurrentCart(); with fetchWithAuth

Any ideas what is wrong, or how to solve it?
"requestId": "1744889635.113130843358932815097",

sacred fossil
#

Why are you using fetchWithAuth and then call the native SDK call to get the cart?

granite thunder
#

Sorry for misleading informations. In this case we dont use client.

import { currentCart, checkout } from '@wix/ecom';

const getCurrentCart = async (): Promise<Cart & CartNonNullableFields> => {
try {
return await currentCart.getCurrentCart();
} catch (error) {
console.error('Error fetching cart:', error);
throw error;
}
};

sacred fossil
#

Where do you call it from? From the block? The backend?

#

Also, did you add the Block in the latest release?

granite thunder
#

Its part of widget. On page load is called this code.
In last release I added new backend event. Trying to listen onCartUpdate Event.

#

Removing and reinstalling app + new insert of widget did not helped.

sacred fossil
#

Try to create a proper client then, as described in the above docs

granite thunder
#

it look same, at least at local dev.

import { ecom } from '@wix/site-ecom';

const wixClientCart = createClient({
host: site.host({ applicationId: import.meta.env.VITE_APPLICATION_ID }),
modules: { currentCart },
});

const getCurrentCart = async (): Promise<Cart & CartNonNullableFields> => {
try {
return await wixClientCart.currentCart.getCurrentCart();
} catch (error) {
console.error('Error fetching cart:', error);
throw error;
}
};

Documentation says I DONT NEED to use client in CLI APP. It worked well before.

sacred fossil
sacred fossil
#

Hi @granite thunder Can you release a major and try again?

granite thunder
#

Hello @sacred fossil thanks for the information. Unfortunatelly new major release didnot help. Still 428 Precondition Required on local dev and even on live site. Do you have any further details for the issue?

sacred fossil
#

Do you have the latest request-id?

granite thunder
#

For example
1745394528.35116593205528178721

sacred fossil
#

@granite thunder Are you able to extract the token used in the call via the network? Can you send it to me in DM?

granite thunder
#

Auhthorization header was empty.

Well, after some debugging and reverting everything back it started running (Authorization headers are back), after releasing minor version live site started imidiatelly running.
So I have no clue what was the cause but IT IS RUNNING NOW.

sacred fossil
#

Can you send the token and also the code snippt in DM anyway? Just to understand some things

granite thunder
#

Do you mean Authorziation header? It was empty. Or send me how to get the token?