即使启用了 micronaut cors,跨域请求也被阻止

问题描述

我正在用 micronauts 编写微服务,但在配置 CORS 时遇到了麻烦。 我查看了其他一些 SO 问题以及文档,但是当我尝试从本地前端应用访问我的服务时,出现以下错误

Cross-Origin Request Blocked: The Same Origin Policy disallows reading the remote resource at http://localhost:8090/my-app/api/endpoint. (Reason: CORS header ‘Access-Control-Allow-Origin’ missing).

这是我当前配置的样子,但我也尝试了不同的变体并获得了相同的结果。

micronaut:
  server:
    cors:
      enabled: true
      configurations:
        allowedOrigins:
          - '*'
        exposedHeaders:
          - Content-Type
          - Authorization
          - '*'
      single-header: true
    netty:
      maxHeaderSize: 1024
      worker:
        threads: 4
      parent:
        threads: 4
      childOptions:
        autoRead: true
  application:
    name: myapp

在春天,我只会将@CrossOrigin 添加到我的端点方法中,我认为 micronauts 中没有替代方案? 我应该以不同的方式配置我的服务器吗?

谢谢!

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)