Stefan Vitória
Stefan Vitória
WWasp
Created by fustuk. on 1/12/2025 in #🙋questions
Weird vscode bug
It happened to me before, but only thing that fixed was restarting vscode
17 replies
WWasp
Created by Stefan Vitória on 12/29/2024 in #🙋questions
CORS ERROR
Not yet. I am taking sometime off before going to it. Because i am kind of stuck doing the same thing. Maybe its one of the thing you said. I will check it later and let you know about it. Thank you by the way.
48 replies
WWasp
Created by Stefan Vitória on 12/29/2024 in #🙋questions
CORS ERROR
Never had this one before, i do have some understanding related to cors, but has said in other chats, the localhost should work out of the box. I did some configurations related to the middleware but didnt work, so i remove them
48 replies
WWasp
Created by Stefan Vitória on 12/29/2024 in #🙋questions
CORS ERROR
I ended up undoing all code related with cors to start over
48 replies
WWasp
Created by Stefan Vitória on 12/29/2024 in #🙋questions
CORS ERROR
I followed what as said in the others questions, but i didnt work at all.
48 replies
WWasp
Created by Stefan Vitória on 12/29/2024 in #🙋questions
CORS ERROR
@miho @Filip
48 replies
WWasp
Created by Stefan Vitória on 12/29/2024 in #🙋questions
CORS ERROR
this is the api
48 replies
WWasp
Created by Stefan Vitória on 12/29/2024 in #🙋questions
CORS ERROR
export const scanQrCodeForMemberValidation: ScanQrCodeForMemberValidation<{}, { success: boolean, data?: any }> = async (req, res, context) => {

console.log(JSON.stringify(req.headers, null, 2))

const { body } = req;

const validationResult = validateMamberSchema.safeParse(body);

if (validationResult.success) {

const { gymSlug, email } = validationResult.data;

const member = await context.entities.Member.findFirst({ where: { email } });

// Notify the gym's display
notifyGym({ gymSlug, data: member });

} else if (validationResult.success === false) {
res.status(400).send({ success: false, data: validationResult.error.errors });
}

res.send({ success: true });
};
export const scanQrCodeForMemberValidation: ScanQrCodeForMemberValidation<{}, { success: boolean, data?: any }> = async (req, res, context) => {

console.log(JSON.stringify(req.headers, null, 2))

const { body } = req;

const validationResult = validateMamberSchema.safeParse(body);

if (validationResult.success) {

const { gymSlug, email } = validationResult.data;

const member = await context.entities.Member.findFirst({ where: { email } });

// Notify the gym's display
notifyGym({ gymSlug, data: member });

} else if (validationResult.success === false) {
res.status(400).send({ success: false, data: validationResult.error.errors });
}

res.send({ success: true });
};
48 replies
WWasp
Created by Stefan Vitória on 12/29/2024 in #🙋questions
CORS ERROR
thats the api call
48 replies
WWasp
Created by Stefan Vitória on 12/29/2024 in #🙋questions
CORS ERROR
const handleSubmit = async (event: React.FormEvent<HTMLFormElement>) => {
event.preventDefault();

try {
const response = await api.post(`/api/validateQrCodeScan`, {
headers: {
"Content-Type": "application/json",
},
body: JSON.stringify({ email, gymSlug: slug }),
});

if (!response.status) {
throw new Error("Erro ao enviar os dados. Tente novamente.");
}

const data = await response.data;
console.log(data);
} catch (error: any) {
alert("Algo deu errado.");
}
};
const handleSubmit = async (event: React.FormEvent<HTMLFormElement>) => {
event.preventDefault();

try {
const response = await api.post(`/api/validateQrCodeScan`, {
headers: {
"Content-Type": "application/json",
},
body: JSON.stringify({ email, gymSlug: slug }),
});

if (!response.status) {
throw new Error("Erro ao enviar os dados. Tente novamente.");
}

const data = await response.data;
console.log(data);
} catch (error: any) {
alert("Algo deu errado.");
}
};
48 replies
WWasp
Created by Stefan Vitória on 12/29/2024 in #🙋questions
CORS ERROR
The feature i am trying to implement is the following: a user scans a qr code, and a web page with a input field is shown, where a user provide a code that identifies him in the platform, the i send this code to the server via post request that triggers a
server-sent events (sse)
server-sent events (sse)
which will send this user info for a client that i subscribed to it, its basically a mechanism for users in a gym to validate their subscription status, and its info will be displayed in the gym monitors or any other devices. When i make this post request via other clients like insomnia, it works with no problem, the entire process, but from the fronted it doesn't
48 replies
WWasp
Created by Stefan Vitória on 12/29/2024 in #🙋questions
CORS ERROR
Hello @Filip i believe i do need human help on this one. Well this is the error:
Access to XMLHttpRequest at 'http://localhost:3001/api/validateQrCodeScan' from origin 'http://localhost:3000/' has been blocked by CORS policy: Response to preflight request doesn't pass access control check: No 'Access-Control-Allow-Origin' header is present on the requested resource.
Access to XMLHttpRequest at 'http://localhost:3001/api/validateQrCodeScan' from origin 'http://localhost:3000/' has been blocked by CORS policy: Response to preflight request doesn't pass access control check: No 'Access-Control-Allow-Origin' header is present on the requested resource.
I am testing it on localhost because its a new feature i am adding to my app. When i try to call this api i endpoint, same app, i get this error, and apparently none of the suggestions given by kappa works, not even the one that worked for the other developer. Wha makes me confuse is when i call the api from insomnia the thing works normally, but when i try to use it from the client, frontend, i get this cors error.
48 replies
WWasp
Created by NEROX on 12/18/2024 in #🙋questions
CORS issue
@kapa.ai this is the api declaration: api scanQrCodeForMemberValidation { httpRoute: (POST, "/api/validateQrCodeScan"), fn: import {scanQrCodeForMemberValidation} from "@src/server/member-validation/api", entities: [Gym, Member, Membership, MembershipPlan], }
export const scanQrCodeForMemberValidation: ScanQrCodeForMemberValidation<{}, { success: boolean, data?: any }> = async (req, res, context) => {

const { body } = req;

const validationResult = validateMamberSchema.safeParse(body);

if (validationResult.success) {

const { gymSlug, email } = validationResult.data;

const member = await context.entities.Member.findFirst({ where: { email } });

// Notify the gym's display
notifyGym({ gymSlug, data: member });

} else if (validationResult.success === false) {
res.status(400).send({ success: false, data: validationResult.error.errors });
}

res.send({ success: true });
};
export const scanQrCodeForMemberValidation: ScanQrCodeForMemberValidation<{}, { success: boolean, data?: any }> = async (req, res, context) => {

const { body } = req;

const validationResult = validateMamberSchema.safeParse(body);

if (validationResult.success) {

const { gymSlug, email } = validationResult.data;

const member = await context.entities.Member.findFirst({ where: { email } });

// Notify the gym's display
notifyGym({ gymSlug, data: member });

} else if (validationResult.success === false) {
res.status(400).send({ success: false, data: validationResult.error.errors });
}

res.send({ success: true });
};
25 replies
WWasp
Created by NEROX on 12/18/2024 in #🙋questions
CORS issue
@kapa.ai i am on wasp 0.14.2
25 replies
WWasp
Created by NEROX on 12/18/2024 in #🙋questions
CORS issue
i am on wasp 0.14.2
25 replies
WWasp
Created by NEROX on 12/18/2024 in #🙋questions
CORS issue
@kapa.ai i am facing the same issue but this doesnt seems to work for me. I am on localhost but still facing this error
25 replies
WWasp
Created by Stefan Vitória on 12/29/2024 in #🙋questions
CORS ERROR
@kapa.ai same thing using fecth
48 replies
WWasp
Created by Stefan Vitória on 12/29/2024 in #🙋questions
CORS ERROR
same thing using fecth
48 replies
WWasp
Created by Stefan Vitória on 12/29/2024 in #🙋questions
CORS ERROR
@kapa.ai it still doesnt work. But i test it using insomnia it works with no problem
48 replies
WWasp
Created by Stefan Vitória on 12/29/2024 in #🙋questions
CORS ERROR
@kapa.ai this is how i am making the request: const response = await api.post(http://localhost:3001/api/validateQrCodeScan, { headers: { "Content-Type": "application/json", }, body: JSON.stringify({ email, gymSlug: slug }), });
48 replies