解决Elasticsearch相关CORS问题

解决Elasticsearch相关CORS问题

运行环境

我用Java编写了一个带有Elastic Search的后端,并使用Maven进行构建和管理。

部署的运行环境是基于Google Cloud Platform(GCP)的。我在此环境中使用Google的Elasticsearch API,并将API部署到Google App Engine (GAE)上。此外,我也在本地环境中运行和测试。

问题描述

在我运行应用程序和进行开发的过程中,我遇到了一个有趣的问题。当我在本地运行应用程序时,一切都正常,没有出现任何错误。然而,当我尝试通过前端访问部署在GCP上的项目时,我遇到了一个报错:

Access to fetch at 'https://XXX.aosnot.com/authenticate/guest' from origin 'https://master.XXX.amolifyapp.com' has been blocked by CORS policy: Response to preflight request doesn't pass access control check: No 'Access-Control-Allow-Origin' header is present on the requested resource. If an opaque response serves your needs, set the request's mode to 'no-cors' to fetch the resource with CORS disabled.

这是一个典型的CORS(跨域资源共享)错误

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值