Compare commits

...

4 Commits

6 changed files with 20 additions and 3 deletions

1
.gitignore vendored
View File

@ -66,6 +66,7 @@ application-dev.yaml
application.properties
application.yaml
application-prod.yaml
application-tencent.yaml
# -----------------------------
# 图片 / 文件上传目录(如有)

View File

@ -10,7 +10,7 @@
</parent>
<groupId>github.benjamin</groupId>
<artifactId>equip-reserve-backend</artifactId>
<version>1.0.2</version>
<version>1.0.3-SNAPSHOT</version>
<name>equip-reserve-backend</name>
<description>equip-reserve-backend</description>
<url/>

View File

@ -7,6 +7,7 @@ import org.springframework.web.cors.CorsConfiguration;
import org.springframework.web.cors.CorsConfigurationSource;
import org.springframework.web.cors.UrlBasedCorsConfigurationSource;
import java.util.Arrays;
import java.util.List;
@Configuration
@ -18,7 +19,7 @@ public class CorsConfig {
@Bean
public CorsConfigurationSource corsConfigurationSource() {
CorsConfiguration config = new CorsConfiguration();
config.setAllowedOriginPatterns(List.of(allowedOrigins));
config.setAllowedOriginPatterns(Arrays.asList(allowedOrigins.split(",")));
config.setAllowCredentials(true);
config.addAllowedHeader("*");
config.addAllowedMethod("*");

View File

@ -32,6 +32,7 @@ public class SecurityConfig {
.authorizeHttpRequests(auth -> auth
.requestMatchers("/login").permitAll()
.requestMatchers("/device_image/**").permitAll()
.requestMatchers("/health").permitAll()
.anyRequest().authenticated())
.addFilterBefore(jwtAuthFilter(), UsernamePasswordAuthenticationFilter.class)
.build();

View File

@ -0,0 +1,14 @@
package github.benjamin.equipreservebackend.controller;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RestController;
@RestController
public class HealthController {
@GetMapping("/health")
public String health() {
return "ok";
}
}

View File

@ -16,7 +16,7 @@ jwt:
secret: your-secret
equip-reserve:
device-days: 7
allowed-origins: http://localhost:5173
allowed-origins: "http://localhost:5173,http://127.0.0.1:5173"
mybatis-plus:
mapper-locations: classpath:mapper/*.xml
configuration: