I am using the " Token Based Auth" plugin in my Weweb app but I am running into an issue as the API call to fetch the user which is within the plugin settings doesn’t work. I suspect that it is because we don’t have that option to “Make this request through a server” which we do have when adding a REST API action.
As a result, I believe the API call to fetch the user is being sent as OPTIONS instead of a GET.
Is there a way to control this or find a solution to it?
Perhaps allow us to define the request type OR allow us to store the user object into the plugin’s used variables?
I think the OPTIONS call is a CORS preflight request.
The browser will automatically send a preflight request every time you try to send a request to a different origin, (unless it is a simple request).
It is automatic browser behaviour, weweb is not switching the request method.
The endpoint called should be able to handle this kind of requests.
Correct, but what’s strange is that the OPTIONS is not followed by another request even if the backend is sending something like a 200 OK response to the options.
I think just 200 OK is not enough. The response needs to have some CORS related headers (‘Access-Control-Allow-Origin’, ‘Access-Control-Allow-Methods’, ‘Access-Control-Allow-Headers’).
Of course you can check if this is what is happening in the network panel of the developer tool in your browser.
We are returning these values with the response as you have suggested.
On Postman, it is receiving the headers from our BE correctly.
No it doesn’t work @dorilama
Perhaps if we had that toggle to send the request through the WeWeb server that could resolve it…