403透過AEM Service路由的Edge Delivery GraphQL端點禁止錯誤
對AEM as a Cloud Service中的原生GraphQL端點發出POST請求 — 透過Adobe Edge傳送服務路由的網站會導致 403禁止存取 錯誤。 解決方法是更新反向連結OSGi設定,明確允許GraphQL路徑、信任的主機模式和HTTP方法。
說明 description
環境
- Adobe Experience Manager (AEM) as a Cloud Service — 網站
- Adobe Edge Delivery Service (EDS)
問題/症狀
GraphQL POST要求會在下列條件下成功:
- 直接使用Postman或curl等工具存取發佈網域時。
- 當要求源自本機前端開發環境時。
但是,透過Adobe Edge Delivery Service路由時,相同的要求會失敗,並產生 403 Forbidden 回應。 觀察包括:
- OPTIONS呼叫傳回 200確定。
- POST呼叫傳回 403禁止存取。
組態已驗證
已確認下列設定已正確設定:
- Dispatcher篩選器允許路徑
/content/cq:graphql/.*的GET、POST和OPTIONS方法。 ReferrerFilter、CORSFilter和CSRFPreventionFilter的OSGi設定已設定為允許GraphQL要求。- 必要的標頭(
Origin、Host、Content-Type)存在且未移除。
解決方法 resolution
若要解決此問題,請使用下列設定更新反向連結OSGi設定(org.apache.sling.security.impl.ReferrerFilter.cfg.json):
-
新增應該允許的路徑(
allow.paths):/content/cq:graphql/.*
-
使用規則運算式設定允許的主機以符合網域(
allow.hosts.regexp):https://.*\.adobe\.com(:443)?https://.*\.adobe\.net(:443)?https://.*\.workfront\.com(:443)?https://.*\.workfront-dev\.com(:443)?https://.*\.dev\.workfront\.tech(:443)?https://.*\.aem\.live(:443)?
-
將
filter.enabled設定為 true 以啟用篩選。 -
將
allow.empty設定為 true,允許清空反向連結。 -
指定允許的HTTP方法:
- GET
- POST
- OPTIONS
範例反向連結OSGi設定:
{
"allow.paths": [
"/content/cq:graphql/.*",
] ,
"allow.hosts.regexp": [
"https://.*\\.adobe\\.com(:443)?",
"https://.*\\.adobe\\.net(:443)?",
"https://.*\\.workfront\\.com(:443)?",
"https://.*\\.workfront-dev\\.com(:443)?",
"https://.*\\.dev\\.workfront\\.tech(:443)?",
"https://.*\\.aem\\.live(:443)?"
] ,
"filter.enabled": true,
"allow.empty": true,
"allow.methods": [ "GET", "POST", "OPTIONS"]
}
如需其他內容,請參閱此社群討論區這裡。
recommendation-more-help
3d58f420-19b5-47a0-a122-5c9dab55ec7f