المساعد الشخصي الرقمي

مشاهدة النسخة كاملة : حل مشكلة Access-Control-Allow-Origin not working



Rise Company
12-11-2023, 13:14
حل مشكلة Access-Control-Allow-Origin not working
حل مشكلة cpanel header('Access-Control-Allow-Origin: *');
How to enable CORS in your hosting account?

https://www.rise.company/upload/uploads/169978881688381.png

If you are a developer and need CORS enabled to run your app you can enable it adding the following lines in the .htaccess file in your hosting account.

افتح ملف .htaccess وضع بداخله هذا السطر وهتجد انه يعمل بشكل سليم



<IfModule mod_headers.c>
Header set Access-Control-Allow-Origin "*"
</IfModule>



Other option is also enable the headers in your script if you are using PHP, for example:


<?php
header("Access-Control-Allow-Headers: Authorization, Content-Type");
header("Access-Control-Allow-Origin: *");
header('content-type: application/json; charset=utf-8'); ?>


المرجع:
https://secure.plusplushosting.net/knowledgebase/1517/How-to-enable-CORS-in-your-hosting-account.html
https://forums.cpanel.net/threads/access-control-allow-origin-not-working.664637/