Issue Description:
Current Behavior
When fetching product details via the Square API, we observe inconsistent results between localhost and the Vercel-deployed environment. Specifically:
- On localhost, the
image_ids
field in the response includes all associated images (e.g., two images for a product). - On Vercel, the
image_ids
field returns only one image, even when additional images were recently added.
Expected Behavior
The image_ids
field should consistently return all associated images for a product across both environments, ensuring data uniformity.
Steps to Reproduce:
- Deploy the API endpoint to Vercel.
- Fetch product details for a specific product using the following API route:
https://connect.squareup.com/v2/catalog/object/{product_id}
- Compare the
image_ids
field in the JSON response between localhost and the Vercel deployment.
Example Response Discrepancy:
- Localhost:
"image_ids": ["img_1", "img_2"]
- Vercel:
"image_ids": ["img_1"]
Configuration and Environment Details:
-
Project URL: [Your Project URL]
-
Framework: Next.js
-
Environment:
- Localhost: Node.js version [Your Local Version]
- Vercel: Node.js version [Configured on Vercel]
-
Square API Endpoint Used:
GET /v2/catalog/object/{id}
Code Snippet:
Below is the relevant code used to fetch the product data:
const response = await fetch(`https://connect.squareup.com/v2/catalog/object/${id}`, {
method: 'GET',
headers: {
'Authorization': `Bearer ${process.env.SQUARE_ACCESS_TOKEN}`,
'Content-Type': 'application/json',
},
});
const data = await response.json();
Troubleshooting Done:
- Confirmed that the API endpoint works as expected in a local environment.
- Verified that the
process.env.SQUARE_ACCESS_TOKEN
is correctly configured and accessible in both environments. - Reproduced the issue consistently, ruling out transient API issues.
Hypothesis:
The issue may stem from:
- API response caching or rate-limiting behavior on Vercel.
- Differences in environment settings (e.g., headers, middleware, or proxy configurations).
- A potential bug in how the Vercel deployment interacts with Square’s API.
Request:
Please advise on debugging steps or potential fixes for ensuring consistent API responses between local and deployed environments. Additionally, let us know if there are any specific Vercel-related configurations or settings that might influence this behavior.