I have a React frontend and a FastAPI backend. When I try to query the backend via the frontend, I get an error.
axios.post(myUrl, { key : "val" } );
>>>
Confirmation.js:227
POST <myUrl> 405 (Method Not Allowed)
Now the thing that’s really curious is that I can query from Python in a ipynb
r = requests.post(myUrl, json={key:"val"})
j = json.loads(r.text)
j['statusCode']
>>>
200
You might naturally wonder, what about CORS?
This is the CORS settings that I’ve defined via FastAPI
app.add_middleware(
CORSMiddleware,
allow_origins=['*'],
allow_methods=['*'],
allow_headers=['*']
)
Perhaps I’m missing something… Why might CORS settings 1/ have no effect on axios requests but 2/ work just fine from a Python notebook running on a different server?