Skip to content

Commit

Permalink
fix: 修改后台管理页面为直接渲染而不是重定向,以更好的兼容反向代理(#2254)
Browse files Browse the repository at this point in the history
  • Loading branch information
8Q757 committed Jul 19, 2022
1 parent 7eef3b7 commit 9dc510b
Showing 1 changed file with 7 additions and 11 deletions.
18 changes: 7 additions & 11 deletions src/main/java/run/halo/app/controller/content/MainController.java
Original file line number Diff line number Diff line change
Expand Up @@ -50,11 +50,9 @@ public MainController(UserService userService, OptionService optionService,
}

@GetMapping("${halo.admin-path:admin}")
public void admin(HttpServletResponse response) throws IOException {
String adminIndexRedirectUri =
HaloUtils.ensureBoth(haloProperties.getAdminPath(), HaloUtils.URL_SEPARATOR)
+ INDEX_REDIRECT_URI;
response.sendRedirect(adminIndexRedirectUri);
public String admin() throws IOException {
return HaloUtils.ensureBoth(haloProperties.getAdminPath(), HaloUtils.URL_SEPARATOR)
+ INDEX_REDIRECT_URI;
}

@GetMapping("version")
Expand All @@ -64,14 +62,12 @@ public String version() {
}

@GetMapping("install")
public void installation(HttpServletResponse response) throws IOException {
public String installation() throws IOException {
boolean isInstalled = optionService
.getByPropertyOrDefault(PrimaryProperties.IS_INSTALLED, Boolean.class, false);
if (!isInstalled) {
String installRedirectUri =
StringUtils.appendIfMissing(this.haloProperties.getAdminPath(), "/")
+ INSTALL_REDIRECT_URI;
response.sendRedirect(installRedirectUri);
return StringUtils.appendIfMissing(this.haloProperties.getAdminPath(), "/")
+ INSTALL_REDIRECT_URI;
} else {
throw new NotFoundException("404");
}
Expand Down Expand Up @@ -103,4 +99,4 @@ public void favicon(HttpServletResponse response) throws IOException {
response.sendRedirect(HaloUtils.normalizeUrl(favicon));
}
}
}
}

0 comments on commit 9dc510b

Please sign in to comment.