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}`);
|
console.log(`Fetching from OFF API: ${searchTerm}`);
|
||||||
const auth = getOffAuth();
|
|
||||||
const headers = getOffHeaders();
|
const headers = getOffHeaders();
|
||||||
|
|
||||||
let lastError;
|
let lastError;
|
||||||
for (let attempt = 0; attempt <= MAX_RETRIES; attempt++) {
|
for (let attempt = 0; attempt <= MAX_RETRIES; attempt++) {
|
||||||
try {
|
try {
|
||||||
// Use v2 structured search with brand filter (more reliable than /cgi/search.pl)
|
// 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`, {
|
const response = await axios.get(`${OFF_API_BASE}/api/v2/search`, {
|
||||||
params: {
|
params: {
|
||||||
brands_tags: searchTerm,
|
brands_tags: searchTerm,
|
||||||
@@ -98,7 +98,6 @@ export async function searchBabyProducts(query) {
|
|||||||
headers,
|
headers,
|
||||||
timeout: 10000,
|
timeout: 10000,
|
||||||
validateStatus: (status) => status === 200,
|
validateStatus: (status) => status === 200,
|
||||||
...(auth && { auth }),
|
|
||||||
});
|
});
|
||||||
|
|
||||||
// Check if response is actually JSON (OFF sometimes returns HTML on error)
|
// 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}`);
|
console.log(`Fetching OFF product details: ${barcode}`);
|
||||||
const auth = getOffAuth();
|
|
||||||
const headers = getOffHeaders();
|
const headers = getOffHeaders();
|
||||||
// Use v3 API (recommended) for product details
|
// 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`, {
|
const response = await axios.get(`${OFF_API_BASE}/api/v3/product/${barcode}.json`, {
|
||||||
headers,
|
headers,
|
||||||
timeout: 10000,
|
timeout: 10000,
|
||||||
validateStatus: (status) => status === 200,
|
validateStatus: (status) => status === 200,
|
||||||
...(auth && { auth }),
|
|
||||||
});
|
});
|
||||||
|
|
||||||
if (response.data && response.data.product) {
|
if (response.data && response.data.product) {
|
||||||
|
|||||||
Reference in New Issue
Block a user