Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Customer authentication for v2, first PR #328

Merged
merged 1 commit into from
May 24, 2024
Merged

Conversation

sradevski
Copy link
Member

This PR enables the basic interactions with a customer and the auth setup.

A follow-up PR will add all the address-related endpoints, and then we'll do a full e2e test.

Copy link

vercel bot commented May 24, 2024

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
nextjs-starter-medusa ❌ Failed (Inspect) May 24, 2024 11:27am
storefront-v2-staging ✅ Ready (Inspect) Visit Preview 💬 Add feedback May 24, 2024 11:27am

@VariableVic
Copy link
Collaborator

Looks good overall, left a few (non blocking) comments!

Also, build and e2e tests are failing, but that might be an issue for a later PR. We should update the e2e GH Action to work with v2.

import { redirect } from "next/navigation"
import { cache } from "react"

// Note: For some weird reason the response is SOMETIMES a promise here... does it get called like a server action? Investigate.
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Probably due to the "use server" directive. When it's called from a client component, it will be converted into an endpoint. Maybe we could move getAuthHeaders to a separate file and use import "server-only" [source] to prevent this behaviour.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@VariableVic what I would have expected is that, since all the methods that call getAuthHeaders are server actions, this method should just be a normal function call on the server. I'll try your suggestion and see if that fixes it.

return {}
}

export const getCustomer = cache(async function () {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we still need to wrap these in React Cache? Isn't the new js sdk based on fetch instead of Axios? Not blocking but worth looking into. We can also decide to wait until Next 15 is out, as they're changing the default fetch caching behaviour.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@VariableVic probably not, I just kept it as it was. There is a lot of cleanup to be done, which we can do in a separate iteration, I just want to make everything v2 compatible for now 😄

@sradevski
Copy link
Member Author

@VariableVic there is still quite a bit of work to be done, once this PR, and another one that I'll open later today are merged, I'll start to do more thorough testing and fixes, and at that point I think we can also look into the tests

@sradevski sradevski merged commit 87ee1ba into v2 May 24, 2024
3 of 5 checks passed
@sradevski sradevski deleted the feat/add-customer-auth-setup branch May 24, 2024 17:10
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants