I make a React Remix-based Shopify embed app, and wrote an API, the file is called api.access.js in the routes folder.
export async function loader({ request }) {
const { session } = await authenticate.admin(request);
const { shop } = session;
const url = new URL(request.url);
const code = url.searchParams.get("code");
if(code && code !== 'undefined') {
// The next things to do....
}else{
return null;
}
}
Now, when I got the code=MY-CODE from the third-party API and redirect to this page as https://xxxxx.com/api/access?code=MY-CODE, the page will be redirect to the shopify shop login page, so that I can't get the URL param, the codes above was stopped at const { session } = await authenticate.admin(request), then redirected.
Anyone could give me a correct direction that can inspire me to fix this issue.
Thanks!!!
I hope when the third-party app redirects the URL to https://xxxxx.com/api/access?code=MY-CODE, I can get the code=MY-CODE as well as the shop session in the API page.