[SOLVED] Blocked by CORS policy

You could get that error when server is not working, when it gets a timeout or when you have something that blocks that connection like a vpn.

The server is running fine and I can even make calls via the js console

Can you look in browser network tab to see what it says there?

That is browser console. Browser network is somewhere near console, it is something different.

yes, this is the network tab

for me it worked if I paste directly in browser https://owexnxuzf2ev.usemoralis.com:2053/server/functions/createAvatar

Ok any idea what may be causing the cors policy error?

try to see if it works in the browser directly

Ok I just got one that passed and one that failed upon a single submission

Weird though

Yeah it works in the browser

ok, then try with http://127.0.0.1:3000’ instead of http://localhost:3000’

2022-04-29T19:24:24.096Z - ReferenceError: user is not defined

Moralis info logs
Error: {“message”:“user is not defined”,“code”:141}

1 single submission and it seems to be firing 2 times, perhaps this is the issue

1 fail 1 passs

that is expected one is OPTIONS for Request Method

click on the one where it says bad request

2 Likes

Seems there are 2 calls made one is a “post” and one is an “options”

{“code”:142,“error”:“Validation failed. Please login to continue.”}

Getting validation failed probably because of the “requireUser: true”

So the cors issues seems to have stop, not im getting set errors and user not defined

This fixed the CORS issue, thank you!

1 Like