fix(backend): remove auth from OFF read operations
- READ operations don't require auth per OFF docs (only User-Agent) - Auth credentials were causing 503 errors - Keep User-Agent header which is required
This commit is contained in:
@@ -83,13 +83,13 @@ export async function searchBabyProducts(query) {
|
||||
}
|
||||
|
||||
console.log(`Fetching from OFF API: ${searchTerm}`);
|
||||
const auth = getOffAuth();
|
||||
const headers = getOffHeaders();
|
||||
|
||||
let lastError;
|
||||
for (let attempt = 0; attempt <= MAX_RETRIES; attempt++) {
|
||||
try {
|
||||
// Use v2 structured search with brand filter (more reliable than /cgi/search.pl)
|
||||
// READ operations don't require auth per OFF docs, only User-Agent
|
||||
const response = await axios.get(`${OFF_API_BASE}/api/v2/search`, {
|
||||
params: {
|
||||
brands_tags: searchTerm,
|
||||
@@ -98,7 +98,6 @@ export async function searchBabyProducts(query) {
|
||||
headers,
|
||||
timeout: 10000,
|
||||
validateStatus: (status) => status === 200,
|
||||
...(auth && { auth }),
|
||||
});
|
||||
|
||||
// Check if response is actually JSON (OFF sometimes returns HTML on error)
|
||||
@@ -159,14 +158,13 @@ export async function getBabyProductDetails(barcode) {
|
||||
}
|
||||
|
||||
console.log(`Fetching OFF product details: ${barcode}`);
|
||||
const auth = getOffAuth();
|
||||
const headers = getOffHeaders();
|
||||
// Use v3 API (recommended) for product details
|
||||
// READ operations don't require auth per OFF docs, only User-Agent
|
||||
const response = await axios.get(`${OFF_API_BASE}/api/v3/product/${barcode}.json`, {
|
||||
headers,
|
||||
timeout: 10000,
|
||||
validateStatus: (status) => status === 200,
|
||||
...(auth && { auth }),
|
||||
});
|
||||
|
||||
if (response.data && response.data.product) {
|
||||
|
||||
Reference in New Issue
Block a user