apache / shenyu

Apache ShenYu is a Java native API Gateway for service proxy, protocol conversion and API governance.
https://shenyu.apache.org/
Apache License 2.0
8.45k stars 2.94k forks source link

[Question] How to change Shenyu Admin's contextPath #4531

Closed daanhan closed 1 year ago

daanhan commented 1 year ago

Question

期望通过路径localhost:9095/shenyuadmin来访问admin页面。

在admin工程的application.yml文件中添加server.servlet.contextPath=/shenyuadmin,可以让springboot接口修改了路径。 但vue相关的js和html代码中,无法方便的调整路径。 建议vue中相关代码使用相对路径来访问java接口,或提供合适的修改方式,谢谢!

I hope to browse localhost:9095/shenyuadmin to use Shenyu Admin. When add server.servlet.contextPath=/shenyuadmin to application.yml file, it can not change absolution API path in VUE js and html files. I propse change the absolution API path to relative path, in case we change contextPath in springboot.

yu199195 commented 1 year ago

hi,can you fix it?

daanhan commented 1 year ago

@yu199195 Hello! can not find the location of Admin UI project. Please show it.

yu199195 commented 1 year ago

@daanhan https://github.com/apache/shenyu-dashboard

VampireAchao commented 1 year ago

你可以通过shenyu-dashboard/src/index.ejs来设置 例如src/index.ejs:30

  <div id="httpPath" style="display: none" th:text="<%='$'%>{domain}">${process.env.NODE_ENV === 'production' ? '' : 'http://localhost:9095'}</div>

可以修改为

  <div id="httpPath" style="display: none" th:text="<%='$'%>{domain}">${process.env.NODE_ENV === 'production' ? '/shenyuadmin' : 'http://localhost:9095/shenyuadmin'}</div>

即可实现