Home  >  Article  >  Topics  >  How to solve cross-domain problems in Pagoda Linux panel

How to solve cross-domain problems in Pagoda Linux panel

藏色散人
藏色散人forward
2021-03-04 11:35:5611003browse

The following tutorial column of Pagoda will introduce to you the Pagoda Linux panel to solve cross-domain problems. I hope it will be helpful to friends in need!

How to solve cross-domain problems in Pagoda Linux panel

First about cross-domain What is https://baike.baidu.com/item/...
The Pagoda Linux panel is a server panel that is relatively friendly to novices, but it cannot avoid some common server problems such as cross-domain problems:
Website》Select Website》Configuration File
Solution

add_header 'Access-Control-Allow-Origin' '*';
add_header 'Access-Control-Allow-Credentials' 'true';
add_header 'Access-Control-Allow-Methods' 'GET, POST, OPTIONS';

Go to this page and paste the above code at the bottom, and then restart the server
How to solve cross-domain problems in Pagoda Linux panel

Here is a json data of prepared music that can be tested
http://101.200.141.4/api/musi...

juqery:
$.ajax({
    type: "get",
    url: "http://101.200.141.4/api/music.json",
    success: function (response) {
        console.log(response.name);
        console.table(response.data);
    }
});
在vue中可以安装vue-axios进行请求

The above is the detailed content of How to solve cross-domain problems in Pagoda Linux panel. For more information, please follow other related articles on the PHP Chinese website!

Statement:
This article is reproduced at:segmentfault.com. If there is any infringement, please contact admin@php.cn delete