Hi community,
I’m building a checkout extension for my store that adds a post-purchase survey to the thank you page. The goal is to collect referral source data from customers and send it to my backend server at app.artface.club.
I’ve run into a confusing issue with making API calls:
- When I use a relative URL (“/api/v1/referral_source”), the code runs but fails because it’s an incomplete URL.
- When I use the full URL (“https://app.artface.club/api/v1/referral_sources”), the extension fails to deploy silently - it shows “Draft updated successfully” but keeps the old version.
I’ve configured everything I can think of:
- Enabled network access in the Shopify partner dashboard
- Set network_access = true in the TOML
- Verified the application_url in shopify.app.toml
Here’s my extension configuration:
[extensions.capabilities]
api_access = true
network_access = true
And here’s the fetch code that’s causing issues:
async function handleSubmit() {
setLoading(true);
try {
console.log('Attempting to submit to API...');
const response = await fetch('https://app.artface.club/api/v1/referral_sources', {
method: 'POST',
headers: {
'Content-Type': 'application/json',
},
body: JSON.stringify({
referral_source: {
source: 'ad',
detail: 'test'
}
})
});
// ... rest of the function
} catch (error) {
console.error('Error submitting to API:', error);
setLoading(false);
}
}
I expected the extension to either:
- Automatically prepend the application_url to relative URLs, or
- Allow the full URL since I’ve enabled network access
What is the correct way to configure and make API calls to an external server from a checkout extension? Has anyone successfully implemented this pattern?
Thanks in advance for any help!