JHipster非角度登陆页面

前端之家收集整理的这篇文章主要介绍了JHipster非角度登陆页面前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。
我想在JHipster项目中使用普通的html视图作为登陆页面. Spring-Boot控制器是否有最佳实践?我的目标是为路径“/”使用非角度html页面. angular-index.html由spring boot默认值自动加载.我不明白我如何使用弹簧靴的这种自动配置,同时对路径“/”有一个非角度的视图.

@RequestMapping("/")
public String hi() {
    return "hi";
}

这是呈现位于/ resources / templates中的“hi.html”视图的方法.视图显示正确但我无法再处理角度应用程序(例如/ home).

解决方法

JSHipster – 可以使用html5路由,这意味着你去Root JSHipset是在浏览器上使用路由.由此得出它使用了角度路由.

但是,当您使用部分路由’/ api / *’时,它会执行您的后端路由.您可以在application.yml中配置此路由.

enter image description here

问题是当你去rootPath jHipset转到index.html时它是Angular app.

我认为良好的做法是在服务器上设置重定向.

Jhipster可以使用NGINX.

你必须创建一个src / main / docker / Nginx.yml Docker Compose文件

version: '2'
services:
  Nginx:
    image: Nginx:1.13-alpine
    volumes:
    - ./../../../target/www:/usr/share/Nginx/html
    - ./Nginx/site.conf:/etc/Nginx/conf.d/default.conf
    ports:
    - "8000:80"

添加./Nginx/site.conf并配置:

server {
    listen 80;
    index index.html;
    server_name localhost;
    error_log  /var/log/Nginx/error.log;

    location / {
        root /usr/share/Nginx/html; //add path to another html file
    }
    location /api {
        proxy_pass http://api.jhipster.tech:8081/api;
    }
    location /front {
        proxy_pass http://api.jhipster.tech:8081/;
    }

    ...
}

规则位置/您可以更改为自定义URL(无角度视图).

猜你在找的Angularjs相关文章