My shopify app proxy information:
Subpath prefix: apps
Subpath: rma
Host: https://www.example.com/shopdevc/shopifyAPI/
If I query the host directly using https://www.example.com/shopdevc/shopifyAPI/apps/rma, it works great.
But, in my React function, querying "/apps/rma" returns
<!DOCTYPE html> <html lang="en"> <head> <script type="module" src="/@vite/client"></script> <script type="module"> import RefreshRuntime from "/@react-refresh" RefreshRuntime.injectIntoGlobalHook(window) window.$RefreshReg$ = () => {} window.$RefreshSig$ = () => (type) => type window.__vite_plugin_react_preamble_installed__ = true </script> <meta charset="UTF-8" /> </head> <body> <div id="app"><!--app-html--></div> <script type="module" src="/src/entry-client.jsx"></script> </body> </html>
Is there something wrong with my proxy url or path? My folder structure is
"c:\wwwroot\shopDevC\shopifyAPI\apps\rma\index.aspx"
where index.aspx is the default document.
My code:
function delayed_render(async_fun, deps=[]) {
const [output, setOutput] = useState();
useEffect(async () => setOutput(await async_fun()), deps);
return (output === undefined) ? null : output;
}
function TestAPI() {
return delayed_render(async () => {
// const resp = await fetch(`https://www.example.com/shopdevc/shopifyAPI/apps/rma`); // this works fine
const resp = await fetch(`/apps/rma`); //this does not work even though our proxy is set to https://www.example.com/shopdevc/shopifyAPI
const data = await resp.text();
return <div>
<h1> Fetch data from an api in react: {data} </h1>
</div>;