因服务端脚本语言不同,自行搜索设置

2. 前端Ajax跨域请求代码

$.ajax({
                type: "POST",
                url: "http://127.0.0.1:8000/api/login",
                data: JSON.stringify({'num': 1}),
                dataType: 'json',
                xhrFields: {
                    withCredentials: true //允许跨域带Cookie
                },
                success: function(data) {
                    console.log(data)
                }
            })

相关文章: