Back

Appwrite Python function returning status 405 but client receiving 200

  • 1
  • Web
  • Cloud
CodePanda
10 Jun, 2024, 01:24

I am including appwrite using the following in my client side html

TypeScript
      <script src="https://cdn.jsdelivr.net/npm/appwrite@14.0.1"></script>

I have a weird scenario playing out where in I have a python based function, where I dumped just before the endpoint returns and the output is showing

{'body': '{"error": "Method Not Allowed - POST", "Scenario": "42d0d764-a729-41e5-a8f4-1c1b7ec0b5ec"}', 'status': 405, 'headers': { 'Content-Type': 'application/json', 'Access-Control-Allow-Origin': 'https://mysubdomain.mydomaincom/', 'Access-Control-Allow-Methods': 'POST, OPTIONS', 'Access-Control-Allow-Headers': 'Content-Type, Authorization' } }

which is exactly what it needs to be.

But on web client (plan JS) side I have the attached JS code and I am seeing the following output

POST REST API responded with status: 200 POST REST API responded with status text: POST REST API headers:: [Array(2)] POST REST API response data:: {error: 'Method Not Allowed - POST', Scenario: '42d0d764-a729-41e5-a8f4-1c1b7ec0b5ec'}

How is it that the body data is intact, but the status got switched from 405 to 200?

TL;DR
Appwrite Python function returning status 405 but client receiving 200. Browser-side JS shows status 200 despite Python function correctly returning 405. The discrepancy may be due to CORS misconfiguration. Ensure server-side and client-side CORS settings match to prevent status code mix-up.
Reply

Reply to this thread by joining our Discord

Reply on Discord

Need support?

Join our Discord

Get community support by joining our Discord server.

Join Discord

Get premium support

Join Appwrite Pro and get email support from our team.

Learn more