Cors error

Website URL

Hi, i build an api and integrate in my react js project.
My hosting have ssl install
I got an error : CORS Error

I aleady add header
header(‘Content-Type: application/json’);

header(‘Access-Control-Allow-Origin: *’);

header(‘Access-Control-Allow-Methods: POST, OPTIONS’);

header(‘Access-Control-Allow-Headers: Content-Type, Authorization’);

Error Message

CORS ERROR

Help to resolve the problem. It’s not solving from my account

Are you getting this error on localhost or the hosted domain? Please note that you can’t access websites/apis hosted on InfinityFree from another domain (including localhost). If you want to test your API on localhost you will have to setup a local php server and proxy all api requests to it.

6 Likes

I don’t think this is related to IF’s services.

It very much is, and @Dev-I-J answer is mostly correct.

You cannot host APIs here at all since all non-browser devices are blocked.

5 Likes

You can host a React.js project with us, including the PHP backend. However, the backend and the website MUST be hosted on the exact same domain name. So if your React site is on www.example.com, the PHP backend must also be hosted on www.example.com. You cannot host the frontend elsewhere or the backend on another domain or subdomain (even api.example.com would not work).

Please keep in mind that we provide website hosting, not API hosting, and there are some restrictions to enforce that.

5 Likes

Thanks for your reply. Not i am understand the limitation of the free plan hosting service.

infinityfree, doing great job to provide the free platform.

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