I’m working on a custom Hydrogen + Remix storefront, and I’m running into something strange with the /account
routes.
I’ve implemented my own customer login system, using the customerAccessTokenCreate
mutation and storing the token in a custom session (via createCookieSessionStorage
). Here’s a quick summary of the flow:
- A custom
/account/login
page sends the login credentials to Shopify via GraphQL - If successful, I store the
customerAccessToken
andcustomerAccessTokenExpiresAt
in a session cookie - The session is then used in other routes to protect
/account
pages - I have a
useAuth()
hook that reads the current auth state from the root loader
Example: My login handler
/routes/login
const data = await storefront.mutate(CUSTOMER_ACCESS_TOKEN_CREATE_MUTATION, { ... });
session.set('customerAccessToken', data.customerAccessToken.accessToken);
session.set('customerAccessTokenExpiresAt', data.customerAccessToken.expiresAt);
return redirect('/', {
headers: {
'Set-Cookie': await session.commit(),
},
});
The Issue
Even after:
- Replacing
account.tsx
andaccount.$.tsx
with blank files - Deleting any calls to
context.customerAccount.handleAuthStatus()
- Removing the
account.authorize.tsx
file entirely
I’m still being redirected to Shopify’s OAuth login page, with a URL like:
https://shopify.com/authentication/....../oauth/authorize?client_id=…
This happens any time I try to visit /account
— even when those route files are essentially empty. My main goal was to use my own code the check if a user is logged in and then allow them to access their accounts page with my own auth check code. But for some reason with deleting all code in those account files, I am STILL redirected to that account/authorize route.
Is there some internal behavior (maybe in Hydrogen or remix-oxygen) that auto-forwards to Shopify login under certain conditions?
Or am I missing something else that might still be triggering the redirect?