fix: Add SALEOR_API_TOKEN auth for COD transaction creation

- Add SALEOR_API_TOKEN environment variable support
- Update Apollo client to include auth header
- Enable COD transaction creation after checkout
This commit is contained in:
Unchained
2026-03-29 18:22:16 +02:00
parent 5f9b7bac3a
commit e15e6470d2
7 changed files with 921 additions and 173 deletions

View File

@@ -6,12 +6,13 @@ const httpLink = createHttpLink({
});
const authLink = setContext((_, { headers }) => {
// Saleor doesn't require auth for public queries
// Add auth token here if needed for admin operations
// Add auth token for admin operations
const token = process.env.SALEOR_API_TOKEN;
return {
headers: {
...headers,
"Content-Type": "application/json",
...(token && { "Authorization": `Bearer ${token}` }),
},
};
});

View File

@@ -210,3 +210,17 @@ export const CHECKOUT_LANGUAGE_CODE_UPDATE = gql`
}
}
`;
export const TRANSACTION_CREATE = gql`
mutation CreateTransaction($orderId: ID!, $transaction: TransactionCreateInput!) {
transactionCreate(id: $orderId, transaction: $transaction) {
transaction {
id
}
errors {
field
message
}
}
}
`;