Post Purchase Upsell CORS Error when using apps/proxy

rkman
Shopify Partner
1 0 0

I am building Post Purchase Upsell extension using Simplified deployment. Under `ShouldRender` extension point,  I am fetching render data from my app server. The app url differs for each environment and I don't want to hard-code the URL which defeats the purpose of Simplified Deployment. So I am using apps/proxy configuration for making this api call. But the call ends in CORS Error, similar to the issue https://community.shopify.com/c/extensions/cors-issue-with-checkout-ui-extension-fetch-api-app-proxy...

 

I followed the suggestion and made sure that my app has all the necessary "Allow-Origin" headers in the response but the error seems to be coming from App proxy as I don't see any request reaching my server.

 

const fetchCustomerUrl = `https://${inputData.shop.domain}/apps/proxy/token/${inputData.initialPurchase.referenceId}`;
  return fetch(fetchCustomerUrl, {
	credentials: 'include',
	method: 'GET',
	headers: {
		'Content-Type': 'application/json'
	}
  }).then((res) => res.json())

My app server adds the following response header when receiving cross origin requests

 

response.add(new Header(HttpHeaders.ACCESS_CONTROL_ALLOW_METHODS, "POST, GET, OPTIONS, DELETE"))
            .add(new Header(HttpHeaders.ACCESS_CONTROL_ALLOW_HEADERS, "Authorization, Content-Type"))
            .add(new Header(HttpHeaders.ACCESS_CONTROL_ALLOW_CREDENTIALS, "true"))
            .add(new Header(HttpHeaders.ACCESS_CONTROL_ALLOW_ORIGIN, "*"))

 

Replies 0 (0)