Facing 405 For Proxy Server When Calling API from React App

Hello Community,

I’m new to cloud-flare platform.

I’ve hosted a react-app on cloud-flare pages. App is build and deployed fine.
But facing issue when app is trying to communicate with api server getting 405.

My app is hosted on app.xyz.com on cloud-flare platform
My app api are hosted on api.xyz.com on a cloud provider platform.

Am i missing something to enable proxy sever for my app or something else.
My app i working fine on local build connected to same api server not facing any error.

Any help will be really appreciated.



We’d need more details in order to support you here. Can you share the code and a reproduction URL?

405 indicates method not allowed and is usually done if doing a non-GET to Pages. Are you definitely hitting the API and not the Pages site?

Yes i’m hitting the api url as i mentioned earlier the build in working ok on local host hitting the hosted api fine.

But when i deploy build is successful but when app try to make api request it get’s 405.

App URL: app.xyz.com
Proxy Mapped on React app: app.xyz.com/api/* -> rewrite to api.xyz.com
API URL: api.xyz.com

It’s only causing issue on cloudflare pages.

ERROR Getting:

  1. Request URL: https://app.xyz.com/api/auth/login
  2. Request Method: POST
  3. Status Code:405
  4. Remote Address:x.x.x.x:443
  5. Referrer Policy:strict-origin-when-cross-origin

Thanks Walsy for the feedback.

I’ve resolve the issue. Your comments point me to right direction on debugging the issue and resolving it.

Issue was with my api url calling i was expecting the proxy server to work as my mistake which is it for only dev environment soon i made the updates in code to handle prod api url it started working.

This topic was automatically closed 3 days after the last reply. New replies are no longer allowed.