Cloudflare images post api did not work

i have tried few methods from cloudflare api documentations. i want to upload images in my react projects. i have tried axios and fetch method for uploading images but it did not work. when i uploaded it shows me blocked by cors policy. how can i solved it in my react project?

Hello muhai4959

It’s important to understand that making API calls client-side can lead to your API token being exposed, which poses a security risk. You should move your API calls to the server-side of your application. However, if you’re dealing with CORS issues, it’s essential to note that Cloudflare has now added CORS support for Direct Creator Upload. This should alleviate the issue you’re experiencing. Be sure to update the approach you’re using to align with these security practices.

Here is what you can do:

  1. Server-side: Create a server-side script or use serverless function that handles the calls to Cloudflare API.
  2. On the client side: Call this server-side script or function instead of directly calling the Cloudflare API.

Regards,

This topic was automatically closed after 15 days. New replies are no longer allowed.