在生产配置文件中部署jhipster单片应用程序时出现401错误

问题描述 投票:0回答:1

我使用下面的V4.13.0 jhipster选项生成了一个jhipster单片应用程序:

>Monolithic 
> Do not use Jhipster Registry
> authentication (stateless, with a token)
> MySQL in production, H2 in-memory in development
> ehcache
> Gradle
> Angular 5
> Do not enable SASS
> Do not enable i18n
> No testing frameworks
> Do not install other generators

除了jdbc内容,我没有修改application-prod.yml;我的角度环境是

Angular CLI: 1.6.0
Node: 9.3.0
OS: linux x64
Angular: 5.1.0

包装跟随jh指南

./gradlew  -Pprod clean bootRepackage

并运行

build/libs/xx-0.0.1-SNAPSHOT.war 
----------------------------------------------------------
    Application 'xx' is running! Access URLs:
    Local:      http://localhost:8080
    External:   http://127.0.0.1:8080
    Profile(s):     [prod]
----------------------------------------------------------

但当我通过http://localhost:8080的浏览器请求时,它得到了

o.z.p.spring.web.advice.AdviceTrait      : Unauthorized: Full authentication is required to access this resource

浏览器端错误是:

Request URL:http://localhost:8080/api/account
Request Method:GET
Status Code:401 Unauthorized
Remote Address:[::1]:8080
Referrer Policy:no-referrer-when-downgrade

感谢任何人提前和任何帮助!

angular jwt jhipster
1个回答
1
投票

除非我误解了您的问题,否则这是预期的行为:您必须首先对/ api / authenticate进行身份验证以获取令牌,然后使用它来访问/ api / account

© www.soinside.com 2019 - 2024. All rights reserved.