Мое приложениеactjs работает с API.
Мой API написан на языке php и в среде CodeIgniter.
https://github.com/chriskacerguis/codeigniter-restserver
это мой API:
`<?php
defined('BASEPATH') OR exit('No direct script access allowed');
require APPPATH . '/libraries/REST_Controller.php';
class Api extends REST_Controller {
public function __construct($config = 'rest')
{
parent::__construct($config);
$this->load->model('m_user');
$this->load->model('m_cart');
header('Access-Control-Allow-Origin: *');
header("Access-Control-Allow-Headers: X-API-KEY, Origin, X-Requested-With, Content-Type, Accept, Access-Control-Request-Method, Authorization");
header("Access-Control-Allow-Methods: GET, POST, OPTIONS, PUT, DELETE");
}
это мой код реагирования:
function getAll(city) {
const formData = {};
formData['city'] = city;
const requestOptions = {
method: 'POST',
headers: { 'Content-Type': 'multipart/form-data',
'Access-Control-Allow-Origin': '*'},
body: JSON.stringify(formData)
};
return fetch(BASE_URL+serverConstants.COUPONS_POST_REQUEST, requestOptions)
.then(response => {
console.log("======");
console.log(response);
if (!response.ok) {
return Promise.reject(response.statusText);
}
return response.json();
})
Я загрузил свой сайт на поддомен:
test.shadyab.com
my api write на домене shadyab.com.
Вот мой файл htaccess:
AddType application/x-httpd-php56 php56 php
php_flag log_errors on
php_flag display_errors on
#php_value error_reporting 8
php_value error_reporting E_ALL
php_value error_log /home/shadyabc/public_html/error_log2
<IfModule mod_rewrite.c>
RewriteEngine on
RewriteCond %{HTTP_HOST} ^shadyab.com$ [NC]
RewriteRule ^(.*)$ http://www.shadyab.com/$1 [R=301,L]
RewriteCond $1 !^(index\.php|resources|robots\.txt)
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php/$1 [L,QSA]
RewriteCond %{REQUEST_METHOD} OPTIONS RewriteRule ^(.*)$ $1 [R=200,L]
</IfModule>
order allow,deny
allow from all
RewriteCond %{HTTP_HOST} ^shadyab\.ir$ [OR]
RewriteCond %{HTTP_HOST} ^www\.shadyab\.ir$
RewriteRule ^/?$ "http\:\/\/www\.shadyab\.com" [R=301,L]
<Files 403.shtml>
order allow,deny
allow from all
</Files>
deny from 72.52.124.58
Может кто-нибудь, пожалуйста, помогите мне