I know there are multiple threads about this topic, but I have tried all the suggestions and nothing seems to work. So here I am.
I am trying to communicate to an App Proxy from a JS script in a front end page. When I do a Post request via Fetch I get a 404 error. I can access the proxy script on its own without problem.
I don’t know why this is failing. I’m trying to access the proxy app without using a router, so I configured the App proxy with the actual url of the file that will do the processing, as shown below. Can this be the problem? I welcome any suggestions.
Thank you!
This is my setup:
App proxy set Up:
- subpath prefix: apps
- subpath: maker
- proxy URL: https://aaa.ngrok.io/my_app/maker/new_space.php
JS in Shopify’s front end page:
const proxy_url = 'https://my_store.my-shopify.com/apps/maker';
fetch(proxy_url, requestOptions)
.then(async response => {
const isJson = response.headers.get('content-type')?.includes('application/json');
const data = isJson && await response.json();
// check for error response
if (!response.ok) {
// get error message from body or default to response status
const error = (data && data.message) || response.status;
console.error('There was a response error:', error);
}
// element.innerHTML = data.id;
})
.catch(error => {
// element.parentElement.innerHTML = `Error: ${error}`;
console.error('There was an HTTP error:', error);
});
Proxy App File: https://aaa.ngrok.io/my_app/maker/new_space.php
When I access the front end page, I see this error:
```javascript
POST https://my_store.my-shopify.com/apps/maker
[HTTP/2 404 Not Found 305ms]