我遇到了CORS问题。在我的functions/index.js我有:
const cors = require('cors')({
origin: true
});
Run Code Online (Sandbox Code Playgroud)
我的终点是https://sis-t.redsys.es:25443/sis/realizarPago。我需要POST使用来自客户端的适当参数对此URL进行操作,这是在Firebase环境之外。我也有允许外部网络的正确计划,但是向源地址以外的地址发出请求会引发CORS问题:
我已经读到您只需要修改标题,但这仅在您向自己的服务器发出请求时才适用。当您执行时http.onRequest(),您可以在函数内部使用中间件,但是对外部服务器进行POST会发生什么?
这是执行以下操作的axios功能POST:
cardPay: function () {
this.cardProcess = true
axios({
method: 'post',
url: 'https://us-central1-cutre-windrider.cloudfunctions.net/cardPay',
data: {
verifiedUserLogged: this.userLogged.uid,
cart: this.cartItemList,
finalPrice: this.serverPrice,
deliveryInfo: this.userLogged.deliveryAdress,
name: this.userLogged.displayName || false,
email: this.userLogged.email
}
})
.then(response => {
this.requestData = response
this.redsysRedirect(response.data.data)
})
.catch(console.log)
},
redsysRedirect: function (data) {
axios.post('https://sis-t.redsys.es:25443/sis/realizarPago', {
'Ds_SignatureVersion': 'HMAC_SHA256_V1',
'Ds_MerchantParameters': data.merchantParameters,
'Ds_Signature': …Run Code Online (Sandbox Code Playgroud)