add cors
All checks were successful
Deploy App / docker (ubuntu-latest, 2.44.0, 17, 3.8.5) (push) Successful in 1m6s
All checks were successful
Deploy App / docker (ubuntu-latest, 2.44.0, 17, 3.8.5) (push) Successful in 1m6s
This commit is contained in:
parent
b50f01b7f9
commit
a4a29cfa20
25
src/main/java/cc/fascinated/backend/config/Config.java
Normal file
25
src/main/java/cc/fascinated/backend/config/Config.java
Normal file
@ -0,0 +1,25 @@
|
|||||||
|
package cc.fascinated.backend.config;
|
||||||
|
|
||||||
|
import lombok.NonNull;
|
||||||
|
import org.springframework.context.annotation.Bean;
|
||||||
|
import org.springframework.context.annotation.Configuration;
|
||||||
|
import org.springframework.web.servlet.config.annotation.CorsRegistry;
|
||||||
|
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;
|
||||||
|
|
||||||
|
@Configuration
|
||||||
|
public class Config {
|
||||||
|
|
||||||
|
@Bean
|
||||||
|
public WebMvcConfigurer configureCors() {
|
||||||
|
return new WebMvcConfigurer() {
|
||||||
|
@Override
|
||||||
|
public void addCorsMappings(@NonNull CorsRegistry registry) {
|
||||||
|
// Allow all origins to access the API
|
||||||
|
registry.addMapping("/**")
|
||||||
|
.allowedOrigins("*") // Allow all origins
|
||||||
|
.allowedMethods("*") // Allow all methods
|
||||||
|
.allowedHeaders("*"); // Allow all headers
|
||||||
|
}
|
||||||
|
};
|
||||||
|
}
|
||||||
|
}
|
Reference in New Issue
Block a user