Created
April 6, 2021 09:08
-
-
Save rwaddin/112ce785b08e5492a66d1e7fc61339b6 to your computer and use it in GitHub Desktop.
Solve CORS Origin :: My case in vue.js 2 with axios and rest api codeigniter 3.1.11
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 | |
// please place this script to index.php in root folder | |
// in first line after open tag php | |
header('Access-Control-Allow-Origin: *'); | |
header("Access-Control-Allow-Methods: GET, POST, PUT, PATCH, DELETE, OPTIONS"); | |
header("Access-Control-Allow-Headers: X-API-KEY, Origin, X-Requested-With, Content-Type, Accept, Access-Control-Request-Method,Access-Control-Request-Headers, Authorization"); | |
if ($_SERVER['REQUEST_METHOD'] == "OPTIONS") { | |
header("HTTP/1.1 200 OK"); | |
die(); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment