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

Error: Unable to parse value of "$email=undefined". Please quote string values #35

Open
Jaydeep189 opened this issue May 23, 2023 · 9 comments
Labels
bug Something isn't working

Comments

@Jaydeep189
Copy link

I am using credential login with my next.js project with sanity

I have copied the schema from the documentation

my pages/api/sanity/signUp.ts code

import { signUpHandler } from 'next-auth-sanity';

import { createClient } from '@sanity/client';

const client = createClient({
    projectId: process.env.NEXT_PUBLIC_PROJECT_ID,
    dataset: process.env.NEXT_PUBLIC_DATASET || 'production',
    useCdn: true, // set to `false` to bypass the edge cache
    apiVersion: '2023-05-03', // use current date (YYYY-MM-DD) to target the latest API version
    token: process.env.NEXT_PUBLIC_SANITY_API_TOKEN, // or leave blank for unauthenticated usage
});


export default signUpHandler(client);

my signup.tsx code

import { signUp } from 'next-auth-sanity/client';


let email = "[email protected]"
let password = "wanted7575"
let name = "jaydeep"
const user = await signUp({
        email,
        password,
        name,     
});

// rest of the code

I was getting this error

Error: Unable to parse value of "$email=undefined". Please quote string values

So I hardcoded the vales inside my code but the error persists. I don't know what I am doing wrong at this point.

@fedeya fedeya added the bug Something isn't working label May 24, 2023
@fedeya
Copy link
Owner

fedeya commented May 24, 2023

Hi @Jaydeep189 you are using the edge runtime?

@Jaydeep189
Copy link
Author

I am running this locally, via api route provided in nextjs.

I guess it uses edge runtime but I am not sure.

@fedeya
Copy link
Owner

fedeya commented May 25, 2023

@Jaydeep189 i released a new version (1.5.0) with it the signUpHandler can be used on the edge and with the new route handlers (app dir), can you try again with the new version?.

I think this may be related because in the edge there is no req.body

If it doesn't work, can you create a repo to reproduce the bug? because i tried again and everything works fine.

@Jaydeep189
Copy link
Author

I am using Nextjs (12.2.5) version which does not include the app dir,
I have reproduced the error in a new repository that I am sharing with you

https://github.com/Jaydeep189/next-auth-sanity-example

@fedeya
Copy link
Owner

fedeya commented May 25, 2023

Ok this is very strange, I cloned the repo, added the environment variables and started the development server and all works fine. I also tried with Next.js 12.2.5 and it works as well.

image

@Jaydeep189
Copy link
Author

Oh, I didn't check it with postman as a stand alone post request, it works completely fine there, but when I am using this

import { signUp } from 'next-auth-sanity/client';

const user = await signUp({
        email,
        password,
        name,     
});

it gives the error again.

I changed the code to this, and now it is working

fetch("/api/sanity/signUp", {
        body: JSON.stringify({
            name: Data.name,
            password: Data.password,
            email: Data.email
        }),
        headers: {
            "Content-type": "application/json; charset=UTF-8"
        }
    }).then(response => response.json()).then(json => console.log(json));

@fedeya
Copy link
Owner

fedeya commented Jun 28, 2023

the unique difference between your own fetch request and the one made by signUp is the charset in the Content-Type.
I added it in the latest version, can you check again?

@dhatGuy
Copy link
Contributor

dhatGuy commented Jul 6, 2023

Getting the same error. The sign-up was working fine before and suddenly started facing this error.

@anthlasserre
Copy link
Contributor

@dhatGuy @Jaydeep189 Can you, guys, double-check that you haven't exported the signUpHandler under the pages folder ? I made this mistake by following the example-app here. Feel free to check the PR above.

#71

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

4 participants