I'm trying to send a POST request from onesignal api
CODE
axios({
method: 'post',
url: 'https://onesignal.com/api/v1/notifications',
headers: {
'Authorization': 'Basic NTRjZDY1O....',
'Content-type': 'application/json; charset=utf-8',
'Access-Control-Allow-Origin':'*',
'Access-Control-Allow-Methods': 'POST',
'Access-Control-Allow-Headers':'*',
'cache-control': 'no-cache'
},
data: {
"app_id": "8e86143e-00.......",
"contents": {
"en": "test api"
},
"included_segments": [
"All"
]
}
}).catch(function (error) {
if (error.response) {
console.log('error-response-data-'+error.response.data);
console.log('error-response-status-'+error.response.status);
console.log('error-response-headers-'+error.response.headers);
} else if (error.request) {
console.log('error-request-'+error.request);
} else {
console.log('Error', error.message);
}
});
ERROR OUTPUT
XMLHttpRequest cannot load https://onesignal.com/api/v1/notifications Request header field Access-Control-Request-Methods is not allowed by Access-Control-Allow-Headers in preflight response
Would fix it,but it didn't. Does anyone have any information on this error and/or how I can fix it?
i'm using firebase hosting
应在服务器端启用CORS以访问API
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.