I’m still working in sandbox and the Client-Server Backend in the SDK is working great locally. I am getting valid card tokens, and the Client /examples/card.html is able to call the server.js storeCard() function.
However I get 401 unauthorized when the Node backend server tries to call the Square API.
const { result, statusCode } = await square.cardsApi.createCard(cardReq);
[Object: null prototype] {
category: ‘AUTHENTICATION_ERROR’,
code: ‘UNAUTHORIZED’,
detail: ‘This request could not be authorized.’
}
I have my sandbox square access token set in the .env.sandbox file.
I am using: npm run dev
I realize there is a different URL for the Client ajax/fetch calls between sandbox and production:
src=“https://sandbox.web.squarecdn.com/v1/square.js”
is there also a different URL for the Square API, and if so, where do I set that?
Or what am I missing?