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

Is approach not working with ios anymore ? #7

Open
d1sna opened this issue Jan 20, 2024 · 4 comments
Open

Is approach not working with ios anymore ? #7

d1sna opened this issue Jan 20, 2024 · 4 comments

Comments

@d1sna
Copy link

d1sna commented Jan 20, 2024

There is no possible to set "http://" or "https://" instead of "capacitor://" in requests to next-auth, therefore origin and host are different in requests to next-auth and providers urls are not exist in response by server. Do you know about this? is it possible to manage it anyway?

@Kulimantang
Copy link

There is no possible to set "http://" or "https://" instead of "capacitor://" in requests to next-auth, therefore origin and host are different in requests to next-auth and providers urls are not exist in response by server. Do you know about this? is it possible to manage it anyway?

Have you found a solution to this? Am currently trying to make nextauth work with capacitor and I am having the same problems.

@d1sna
Copy link
Author

d1sna commented Feb 20, 2024

There is no possible to set "http://" or "https://" instead of "capacitor://" in requests to next-auth, therefore origin and host are different in requests to next-auth and providers urls are not exist in response by server. Do you know about this? is it possible to manage it anyway?

Have you found a solution to this? Am currently trying to make nextauth work with capacitor and I am having the same problems.

Yes, I've done it, but it was really difficult and not best solution, better to create custom auth for mobile with jwt.
There are some points that i remeber now:

  1. Fetch is not working fine with mobile, especially for auth with credentials (cookie), instead fetch lib u need to use htttp-capacitor official plugin
  2. UseSession from next-auth doesn't have possibility to send request from capacitor://yourdomain to https://yourdomain and you need to create custom UseSession
  3. I created custom provider in next-auth for auth mobile users, used native auth (google, facebook, etc) + custom auth route to authorize, then stored session and cookie in local storage and set it at application start

@Kulimantang
Copy link

Thanks for your reply!! By UseSession() you mean the actual useSession() hook that retrieves the session data in a component? By Custom Provider do you mean A Custom SessionProvider Context or a custom provider as in "EmailProvider" "GoogleProvider" etc?

@d1sna
Copy link
Author

d1sna commented Feb 20, 2024

Thanks for your reply!! By UseSession() you mean the actual useSession() hook that retrieves the session data in a component? By Custom Provider do you mean A Custom SessionProvider Context or a custom provider as in "EmailProvider" "GoogleProvider" etc?

yep, you could not use useSession hook "from the box".

By Custom Provider do you mean A Custom SessionProvider Context or a custom provider as in "EmailProvider" "GoogleProvider" etc?

both, i used custom credentialsProvider (in next-auth file) + native google auth (capacitor plugin)/fb/etc to authroize users, not good solution, but i didnt find another way

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

No branches or pull requests

2 participants