Comments (6)
Hi @junwen-k it´s important to know that next-auth
and @auth/core
is not the same. @auth/core
originated from next-auth
but is not an exact copy.
We published a new version of auth-astro
yesterday, with this we also upgraded @auth/core
to the latest version (0.5.1). Please try this out and make sure you also upgrade @auth/core
in your project.
If your error still happens I´m not sure how much we can do here as it looks like the error lies in the core. Our package is just an Astro wrapper. Also you should not forget that @auth/core
is still in pre-release, meaning it´s not stable yet.
from auth-astro.
Apparently, the typescript compiler error is coming from
Cannot find module 'next-auth/react' or its corresponding type declarations.ts(2307)
Could this be due to pnpm
as well? Not sure if it is related to #9.
I've temporary resolved this by running:
$ pnpm add next-auth -D
I think it should be installed by default when installing this package.
from auth-astro.
I never used pnpm before. Did something similar happen to you before in a different package? Did you
next-auth is listed as a devDependency in the project. This should be enough because we only import types from it. So it´s really weird that it´s not installing in your system.
from auth-astro.
Ok, we actually had our dependencies wrong. Putting it as devDependency was not enough and an error on our side. We still only import types so treeshaking should remove all unnecessary files when you build.
For the original issue about the unexptected response I need to do some more digging.
You´re saying the response is different from the documentation. Did you make sure that the version of the docs is the same as installed? Could you also please give more information on what the actual response is and what you´re expecting?
Thanks for bringing this to our attention.
from auth-astro.
@nowaythatworked Thank you for your reply. First time next-auth
user here and I've been playing around with the configuration.
Apparently, my issue might be related to nextauthjs/next-auth#6512 and it seems like next-auth
team did hi-jack the error on purpose. One way to test this is to create both projects with minimal setup and compare the response with auth-astro
and next-auth
.
According to the documentation here, the signIn
method should return a Promise if redirect is set to false
. This could be changed as I could not find this documentation in authjs.dev website. 🤔
Currently, I am handling error by using the response error
query string. E.g,
utils/error.ts
// Based on specification:
// https://next-auth.js.org/configuration/pages#sign-in-page
export type SignInPageError =
| 'OAuthSignin'
| 'OAuthCallback'
| 'OAuthCreateAccount'
| 'EmailCreateAccount'
| 'Callback'
| 'OAuthAccountNotLinked'
| 'EmailSignin'
| 'CredentialsSignin'
| 'SessionRequired'
| 'Default';
export const getSignInPageError = (url: string) => {
const searchParams = new URL(url).searchParams;
const error = searchParams.get('error') as SignInPageError;
const provider = searchParams.get('provider');
return {
error,
provider,
};
};
index.astro
<button id="login">Login Now!</button>
<script>
const { signIn } = await import('auth-astro/client');
document.getElementById('login')?.addEventListener('click', async () => {
const resp = await signIn('credentials', {
redirect: false,
email: '[email protected]',
password: 'MyPassword',
});
if (resp) {
const { url } = (await resp?.json()) as { url: string };
const { error } = getSignInPageError(url);
if (error === 'CredentialsSignin') {
// Handle error
}
}
});
</script>
Of course, the best way to test this is by creating two minimal setup project for both next-auth
and auth-astro
and comparing the response.
from auth-astro.
@nowaythatworked Thanks for the prompt reply. I'll try with the latest package and see if it resolves the issue. Will reopen this issue should any problems arise.
from auth-astro.
Related Issues (20)
- How to use with Cloudflare Pages env vars? HOT 7
- Add support for api context callback to auth config HOT 1
- Endpoints that should set multiple cookies only set one, causing e.g. callbackUrl to be dropped HOT 1
- Auth configuration filename hidden in README
- AstroAuth (Receiving Undefined Options) HOT 4
- Auth verification error not handled as expected HOT 3
- Make server origin configurable
- Initialize auth config lazily HOT 1
- Session cookies not changing when session is updated HOT 4
- Discord provider is missing user.id in the session object HOT 14
- Outdated @auth/core version HOT 1
- restrict users HOT 1
- AstroAuthHandler attempts to modify immutable headers HOT 4
- Sign In with Credentials Provider always return OK HOT 3
- Can't use getSession inside Vercel edge middleware
- Should support `output=hybrid` + `prerender=false`? HOT 2
- get provider source with getSession HOT 1
- Errors trying to use Keycloak as OIDC provider HOT 3
- Error on cancel login HOT 1
- I connect it with keycloak, how can I obtain the token, to consult an api if it is authenticated
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from auth-astro.