2017-10-04 34 views
0

我有前端的應用程序中的角4和導軌後端5.重定向在軌道上爲預檢角給予響應是無效的錯誤

我已經集成在我的應用程序的支付服務,這將成功響應發佈回給定的url。由於響應是後格式,因此我無法在angular上處理它。因此,我將後端的url作爲重定向url。

現在我想重定向到前端(角)提供支付服務的響應。

在使用Rails redirect_to的方法,它給我的錯誤:

Response for preflight is invalid

但有時候錯誤是

Request header field Authorization is not allowed by Access-Control-Allow-Headers in preflight response.

如何解決這個問題?

回答

0

請參閱以下文檔,並遵循如何避免提前發送請求。如果飛行前請求是必須的,則需要使用正確的方法,來源和標頭在服務器中進行修復。

當發送預檢請求時,將在以下文檔中明確記錄。

https://developer.mozilla.org/en-US/docs/Web/HTTP/Access_control_CORS

In particular, a request is preflighted if any of the following conditions is true: 

If the request uses any of the following methods: 
PUT 
DELETE 
CONNECT 
OPTIONS 
TRACE 
PATCH 
Or if, apart from the headers set automatically by the user agent (for example, Connection, User-Agent, or any of the other header with a name defined in the Fetch spec as a 「forbidden header name」), the request includes any headers other than those which the Fetch spec defines as being a 「CORS-safelisted request-header」, which are the following: 
Accept 
Accept-Language 
Content-Language 
Content-Type (but note the additional requirements below) 
Last-Event-ID 
DPR 
Downlink 
Save-Data 
Viewport-Width 
Width 
Or if the Content-Type header has a value other than the following: 
application/x-www-form-urlencoded 
multipart/form-data 
text/plain 
Or if one or more event listeners are registered on an XMLHttpRequestUpload object used in the request. 
Or if a ReadableStream object is used in the request. 
相關問題