i try to use formik form with yup validation to see if a email already exist in database (i have a nestjs back on the port 8000 and my react front on the port 3000) so i do this:
const validationSchema = Yup.object().shape({
username: Yup.string()
.min(2, 'votre surnom doit contenir minimum 2 caractères')
.max(30, '30 caractères maximum autorisés')
.required('Veuillez renseigner un pseudo'),
email: Yup.string()
.email('Veuillez renseigner une adresse mail valide')
.required('Ce champs est obligatoire.')
.test(
'email check',
'email déjà utiliser',
async (value) =>
await fetch('http:localhost:8000/users/check_email', {
method: 'POST',
headers: {
'Content-type': 'application/json'
},
body: JSON.stringify({ email: value })
}).then((res) => res.json())
),
but when i try to test the email validation i got this error in the console
POST http://localhost:3000/localhost:8000/users/check_email 404 (Not Found)
so how i can change the settings of yup or react to not do this.
CodePudding user response:
You should correct the http protocol in your url from http:localhost:8000/
to http://localhost:8000
so that http://localhost:3000
does not get added at the start of the url.