#Authorization header is invalid after CLI App released
1 messages · Page 1 of 1 (latest)
Why are you using fetchWithAuth and then call the native SDK call to get the cart?
If you want to use the SDK to get the cart, you should authenticate the calls while creating a client
https://dev.wix.com/docs/sdk/articles/set-up-a-client/about-the-wix-client
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;
}
};
Where do you call it from? From the block? The backend?
Also, did you add the Block in the latest release?
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.
Try to create a proper client then, as described in the above docs
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.
Hi Vaci, I will forward it to the relevant team. Can you open a ticket, so we can follow it correctly?
https://www.wix.com/support-chatbot?nodeId=25a57397-ccf7-4376-8b74-48d51edf7159&referral=devRels
Share with me the ticket number so we can cross reference and continue the support there
Hi @granite thunder Can you release a major and try again?
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?
Do you have the latest request-id?
For example
1745394528.35116593205528178721
@granite thunder Are you able to extract the token used in the call via the network? Can you send it to me in DM?
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.
Can you send the token and also the code snippt in DM anyway? Just to understand some things
Do you mean Authorziation header? It was empty. Or send me how to get the token?