Embedded shopify app - refused to connect

Hello
I have created an embedded shopify app in the remix template.
On the /auth/shopify/callback route I want to make a redirect to the app using the command
throw redirect(/app?${searchParams.toString()});
sometimes the app loads correctly and sometimes it displays refused to connect.
Does anyone know what could be the cause?

I don’t think you need to throw a redirect. throw is normally reserved for errors.

Could you try `return redirect(‘/app?${searchParams.toString()}’);

I changed it but it doesn’t solve the problem.

Please check the browser console and network tab. I suspect the code added is causing an infinite loop which is resulting in a refusal to connect.

You’ll be able to see this in the browser dev tools to confirm

When the application does not load correctly and reports a refused to connect error, the following will appear in the network tab:

[same_site_cookies](https://admin.shopify.com/store/{store}/apps?app_id={app-id}&oauth_error=same_site_cookies)

What could be the cause? I will add that the error appears sometimes.