Skip to content

Commit 9b831a9

Browse files
committed
fixed: front-end resource blocked http 401 issues
1 parent 46a4403 commit 9b831a9

File tree

3 files changed

+8
-4
lines changed

3 files changed

+8
-4
lines changed

src/main/java/com/app/login/config/SecurityConfiguration.java

+5-3
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
2020

2121

2222
/**
23-
* Updated SecurityConfiguration for Spring Boot 2.7+
23+
* Updated SecurityConfiguration for Spring Boot 3
2424
* @author Megadotnet
2525
* @date 2024-03-07
2626
*/
@@ -65,7 +65,7 @@ public SecurityFilterChain filterChain(HttpSecurity http) throws Exception {
6565
.requestMatchers("/api/authenticate").permitAll()
6666
.requestMatchers("/api/account/reset_password/init").permitAll()
6767
.requestMatchers("/api/account/reset_password/finish").permitAll()
68-
.requestMatchers("/app/**/*.{js,html}").permitAll()
68+
.requestMatchers("/app/**").permitAll()
6969
.requestMatchers("/bower_components/**").permitAll()
7070
.requestMatchers("/i18n/**").permitAll()
7171
.requestMatchers("/content/**").permitAll()
@@ -75,7 +75,9 @@ public SecurityFilterChain filterChain(HttpSecurity http) throws Exception {
7575
.requestMatchers(HttpMethod.OPTIONS, "/**").permitAll()
7676
.requestMatchers("/v3/api-docs/**").permitAll() // Swagger API 文档
7777
.requestMatchers("/swagger-ui.html").permitAll() // Swagger UI 页面
78-
.requestMatchers("/swagger-ui/**").permitAll()) // Swagger UI 相关资源
78+
.requestMatchers("/swagger-ui/**").permitAll() // Swagger UI 相关资源
79+
.requestMatchers("/static/**").permitAll() // 静态文件
80+
.requestMatchers("/**").permitAll())
7981
.apply(new JWTConfigurer(tokenProvider));
8082

8183
return http.build();

src/main/java/com/app/login/config/WebConfigurer.java

+3
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,8 @@
1515
import jakarta.servlet.ServletContext;
1616
import jakarta.servlet.ServletException;
1717
import jakarta.servlet.ServletRegistration;
18+
import org.springframework.web.servlet.config.annotation.ResourceHandlerRegistry;
19+
1820
import java.io.File;
1921
import java.nio.file.Paths;
2022
import java.util.EnumSet;
@@ -44,6 +46,7 @@ public void onStartup(ServletContext servletContext) throws ServletException {
4446
log.info("Web application fully configured");
4547
}
4648

49+
4750
/**
4851
* Resolve path prefix to static resources.
4952
*/

src/main/resources/templates/error.html

-1
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@
33
xsi:schemaLocation="http://www.thymeleaf.org ">
44
<head>
55
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8"/>
6-
<link rel="shortcut icon" href="${baseUrl}/favicon.ico" />
76
<title>Your request cannot be processed</title>
87
<style>
98
::-moz-selection {

0 commit comments

Comments
 (0)