gpt4 book ai didi

admin - 管理员上的 dropwizard No 'Access-Control-Allow-Origin'

转载 作者:行者123 更新时间:2023-12-03 18:03:53 24 4
gpt4 key购买 nike

当我想从 angular 应用程序访问我的 DropWizard 服务器时,我遇到了问题。
错误是:
XMLHttpRequest cannot load https://localhost:8080/admin/metrics. No 'Access-Control-Allow-Origin' header is present on the requested resource. Origin 'http://localhost:8000' is therefore not allowed access.
我已经看过这里
Dropwizard resolving CORS issues

它实际上适用于以下地址:https://localhost:8080/myResource/list
但不是预先配置的/admin 资源https://localhost:8080/admin/metrics.
似乎表明添加到环境中的过滤器仅用于/api 而不是用于/admin ...

我需要帮助吗?

最佳答案

答案实际上就在您已经看过的那个线程中:

There's support[1] for running the admin routes off of the same port as the main resources. Set your port and adminPort settings to the same value, and then access the admin routes under /admin (e.g. if you were hitting example.com:8081/metrics, go to example.com:8080/admin/metrics instead). Like Ryan said, you'll want to protect everything under /admin, so Dropwizard has built in settings (adminUsername and adminPassword[2]) to let you do this over HTTP basic auth.

1: https://github.com/codahale/dropwizard/blob/master/dropwizard-core/src/main/java/com/yammer/dropwizard/config/ServerFactory.java#L317

2: http://dropwizard.codahale.com/manual/core/#configuration-defaults

Michael

关于admin - 管理员上的 dropwizard No 'Access-Control-Allow-Origin',我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/20677626/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com