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

时间:2017-12-29 10:04:29

标签: angular jwt jhipster

我使用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

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

1 个答案:

答案 0 :(得分:1)

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