Hi, I have been migrating my Vite React application. It is a simple form to send booking data to my client’s CRM tool. They wanted to show up on their Shopify hero section page. I was reading the docs for the Shopify CLI migration step and have been following that.
Migration Doc](Migrate to Shopify CLI 3.x))
I have most of everything set up correctly with my configurations. The only issue I am trying to solve right now is this error: “Error forwarding web request: AggregateError”
My app’s folder structure is following the mono repo setup of what they recommend for the new CLI tooling. So I have the
Root
shopify.app.app-name.toml
Web
shopify.web.toml
… configuration files for frontend project
Frontend
… project specific components files
localhost:5173 works. It is only when I try to see the preview it does not. Here are my terminal messages:
Before looking at preview
After looking at preview
Hi @webcraftio !
Thanks for your reply. The app does not have any auth requirements, and there isn’t any session management like local storage or session storage. I am using react-hook-form to manage the state.
My current CLIversion is : 3.73.1
@Shopify/app version I just installed since it was not there before. It is now in my root package.json:
^3.58.2
With the verbose flag enables here are my logs:
I have edited the vite.config.ts file for the proxy server as you mentioned.
The only part I am unsure of is the .env file. I thought it should use the .toml file. And how would I know what the secret is? I think the API key was auto-generated when I ran the Shopify app dev to link it to my partner account.
So I made some progress I can now see my form, from the Shopify page when I added the @Shopify_77 /app-bridge-react as a provider. And then using ngrok to tunnel my app from localhost onto the vite port of 5173. The error message now is more helpful which states this:
I included the script tag for the app-bridge.js file with my client ID from the CLI and then added this to my main.tsx file:
const isDevelopment = import.meta.env.DEV;
const config = {
development: {
apiKey: process.env.SHOPIFY_API_KEY ?? ‘’,
host: new URL(window.location.href).searchParams.get(‘host’) ?? ‘’,
},
production: {
apiKey: process.env.SHOPIFY_API_KEY ?? ‘’,
host: new URL(window.location.href).searchParams.get(‘host’) ?? ‘’,
},
};
const router = createBrowserRouter(
[
{
path: ‘/’,
element: ,
},
],
{
basename: ‘/’,
}
);
createRoot(document.getElementById(‘root’)!).render(
<ShopifyAppBridgeProvider
config={{
…config[isDevelopment ? ‘development’ : ‘production’],
forceRedirect: true,
}}
);