Ajout du CORS Pour le dev local + toastify + exmpl
tout est dans le titre
This commit is contained in:
@ -1,16 +1,18 @@
|
||||
package ovh.herisson.Clyde.EndPoints;
|
||||
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.CrossOrigin;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
import ovh.herisson.Clyde.Ping;
|
||||
|
||||
@RestController
|
||||
@CrossOrigin(origins = "http://localhost:5173")
|
||||
public class PingController {
|
||||
|
||||
@GetMapping("/ping")
|
||||
public Ping ping(){
|
||||
return new Ping(1, "test");
|
||||
return new Ping(1, "pong");
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -5,6 +5,8 @@ import javax.sql.DataSource;
|
||||
import org.springframework.context.annotation.Bean;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
import org.springframework.jdbc.datasource.DriverManagerDataSource;
|
||||
import org.springframework.web.servlet.config.annotation.CorsRegistry;
|
||||
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;
|
||||
|
||||
@Configuration
|
||||
public class JdbcConfig {
|
||||
@ -20,4 +22,15 @@ public class JdbcConfig {
|
||||
return source;
|
||||
}
|
||||
|
||||
|
||||
@Bean
|
||||
public WebMvcConfigurer corsConfigurer() {
|
||||
return new WebMvcConfigurer() {
|
||||
@Override
|
||||
public void addCorsMappings(CorsRegistry registry) {
|
||||
registry.addMapping("/greeting-javaconfig").allowedOrigins("*");
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
}
|
||||
|
Reference in New Issue
Block a user