Last active
September 18, 2025 05:02
-
-
Save agungsugiarto/28ff3eaf8e64b5a87de85e7f5e2e6b58 to your computer and use it in GitHub Desktop.
Dealing with CORS in CodeIgniter 3
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <?php | |
| defined('BASEPATH') or exit('No direct script access allowed'); | |
| $config = [ | |
| /* | |
| |-------------------------------------------------------------------------- | |
| | Cross-Origin Resource Sharing (CORS) Configuration | |
| |-------------------------------------------------------------------------- | |
| | | |
| | Here you may configure your settings for cross-origin resource sharing | |
| | or "CORS". This determines what cross-origin operations may execute | |
| | in web browsers. You are free to adjust these settings as needed. | |
| | | |
| | To learn more: https://developer.mozilla.org/en-US/docs/Web/HTTP/CORS | |
| | | |
| */ | |
| 'allowed_methods' => ['*'], | |
| 'allowed_origins' => ['*'], | |
| 'allowed_origins_patterns' => [], | |
| 'allowed_headers' => ['*'], | |
| 'exposed_headers' => [], | |
| 'max_age' => 0, | |
| 'supports_credentials' => false, | |
| ]; |
Author
cara penggunaan yang lebih spesifik gak ada pak? seperti hanya domain tertentu ya bisa akses API tersebut
@mdestafadilah bisa di setting melalui config corsnya pada bagian 'allowed_origins' => ['*'], contoh 'allowed_origins' => ['https://google.com', '*.google.com'],
ini nyoba cross domain , manggil login page... tetep nggak bisa ya kalo dimasukin ke Iframe
The syntax private array $allowedOrigins = []; won't work in PHP 7.3.33. Typed properties were introduced in PHP 7.4. You should remove these.
The syntax private array $allowedOrigins = []; won't work in PHP 7.3.33. Typed properties were introduced in PHP 7.4. You should remove these.
thanks.
untuk implementasi di hooks (pre_system) itu gimana mas ?
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
cara penggunaan yang lebih spesifik gak ada pak? seperti hanya domain tertentu ya bisa akses API tersebut