簡體   English   中英

AWS Api 網關不接受帶有提取的選項,而 axios 工作正常

[英]AWS Api Gateway not accepting OPTIONS with fetch while axios works fine

AWS API 網關在 OPTIONS 請求上發送 403 錯誤,使用 fetch 獲取 GET api 調用,並從提琴手獲取以下詳細信息:

HTTP/1.1 403 Forbidden
Date: Fri, 23 Sep 2022 11:50:57 GMT
Content-Type: application/json
Content-Length: 42
Connection: keep-alive
x-amzn-RequestId: 02883556-5b3b-4af7-8c3a-3d561f2e0557
x-amzn-ErrorType: MissingAuthenticationTokenException
x-amz-apigw-id: Y6WFM7rPEF9iQ=

{"message":"Missing Authentication Token"}

雖然相同的 url 與 Axios 請求一起正常工作,但確切的請求細節由提琴手驗證。

獲取請求缺少模式屬性,默認為不允許選項請求的 no-cors,將模式設置為 cors 有效。

return fetch(`${process.env.URL}edit_session/${documentId}?${new URLSearchParams({
                edit_token: editToken,
                action: 'clear'
            })}`, {
                method: 'GET',
                keepalive: true,
                headers,
                mode: 'cors',
                cache: 'no-cache'
            });

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM