( ! ) Notice: session_start(): ps_files_cleanup_dir: opendir(/var/lib/php/session) failed: Permission denied (13) in /home/prototurk.com/public_html/app/init.php on line 4
Call Stack
#TimeMemoryFunctionLocation
10.0005362616{main}( ).../index.php:0
20.0014366432require( '/home/prototurk.com/public_html/app/init.php' ).../index.php:9
30.0015382944session_start ( ).../init.php:4
axios ta has been blocked by CORS policy hatası - PROTOTURK
v2.5.2
Giriş yap

axios ta has been blocked by CORS policy hatası

hasaneryilmaz
1,879 defa görüntülendi

bir kod blogum var ve içinde aşağıdaki kodlar yazmakta.


const ajax = axios.get('http://192.168.1.100/api')
    .then(function (e) {
        console.log(e);
    })
    .catch(function (error) {
        console.log(error);
    });

 

bu isteği alıp ul tagları arasına yazdırmak istiyorum.

burdaki adreste yapı


<li><a href="site.com"><img src="resim.png"/></a></li>

şeklinde

gelelim hataya

Access to XMLHttpRequest at 'http://192.168.1.100/api' from origin 'http://site2.com' has been blocked by CORS policy: Response to preflight request doesn't pass access control check: No 'Access-Control-Allow-Origin' header is present on the requested resource.
Cevap yaz
Cevaplar (1)
tayfunerbilen
1382 gün önce

istek attığın yerde izin vermen lazım eğer php kullanıyorsan http://192.168.1.100/api adresinde şunu eklersen dosyanın başına çözülecektir.

header("Access-Control-Allow-Origin: *");

Diğer örnekler için: https://enable-cors.org/server.html