WSO2 APIM 4.0.0创建API正常但调用返回404及CORS错误如何解决?
排查修改步骤
CORS配置生效范围修正
全局[apim.cors]配置仅对新增API生效,存量已创建的API(包括测试用的pizzashack示例API)需要手动触发规则同步:
进入Publisher平台对应API的「运行配置」页,启用CORS配置,确认规则和全局配置一致后重新发布API。网关标签匹配修正
当前配置存在网关标签不匹配问题,导致API发布后未同步到运行网关,引发404错误。需修改deployment.toml中网关环境配置,补充标签字段:
[[apim.gateway.environment]] name = "Production" type = "production" display_in_api_console = true description = "This is a hybrid gateway that handles both production and sandbox token traffic." show_as_token_endpoint_url = true service_url = "https://apim-p.<redacted dns>.com:${mgt.transport.https.port}/services/" username= "${admin.username}" password= "${admin.password}" ws_endpoint = "ws://apim-p.<redacted dns>.com:9099" wss_endpoint = "wss://apim-p.<redacted dns>.com:8099" http_endpoint = "http://apim-p.<redacted dns>.com:${http.nio.port}" https_endpoint = "https://apim-p.<redacted dns>.com:${https.nio.port}" websub_event_receiver_http_endpoint = "http://apim-p.<redacted dns>.com:9021" websub_event_receiver_https_endpoint = "https://apim-p.<redacted dns>.com:8021" # 新增标签配置,和同步规则的label保持一致 label = "Default"
- 端口与访问验证
确认虚拟机防火墙/安全组已开放以下默认端口:
- 网关HTTPS端口:8243
- 网关HTTP端口:8280
- 管理控制台端口:9443
API发布时选择「Production」网关环境,调用前验证接口地址前缀与网关配置的https_endpoint/http_endpoint完全一致。
- 配置生效验证
修改deployment.toml后重启WSO2 APIM服务,重新发布测试API后再进行调用验证。
内容的提问来源于stack exchange,提问作者Nicolas
相关产品推荐
相关产品推荐

