Ajout du CORS Pour le dev local + toastify + exmpl #38

Merged
tonitch merged 1 commits from ExampleNCors into master 2024-02-27 16:21:51 +01:00
6 changed files with 29 additions and 2 deletions

View File

@ -19,7 +19,7 @@ dependencies {
implementation("org.springframework.boot:spring-boot-starter-jdbc") implementation("org.springframework.boot:spring-boot-starter-jdbc")
implementation("org.springframework.boot:spring-boot-starter-mail") implementation("org.springframework.boot:spring-boot-starter-mail")
implementation("org.springframework.boot:spring-boot-starter-web") implementation("org.springframework.boot:spring-boot-starter-web")
implementation("org.springframework.session:spring-session-jdbc") // implementation("org.springframework.session:spring-session-jdbc")
developmentOnly("org.springframework.boot:spring-boot-devtools") developmentOnly("org.springframework.boot:spring-boot-devtools")
developmentOnly("org.springframework.boot:spring-boot-docker-compose") developmentOnly("org.springframework.boot:spring-boot-docker-compose")
runtimeOnly("org.postgresql:postgresql") runtimeOnly("org.postgresql:postgresql")

View File

@ -1,16 +1,18 @@
package ovh.herisson.Clyde.EndPoints; package ovh.herisson.Clyde.EndPoints;
import org.springframework.web.bind.annotation.GetMapping; import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.CrossOrigin;
import org.springframework.web.bind.annotation.RestController; import org.springframework.web.bind.annotation.RestController;
import ovh.herisson.Clyde.Ping; import ovh.herisson.Clyde.Ping;
@RestController @RestController
@CrossOrigin(origins = "http://localhost:5173")
public class PingController { public class PingController {
@GetMapping("/ping") @GetMapping("/ping")
public Ping ping(){ public Ping ping(){
return new Ping(1, "test"); return new Ping(1, "pong");
} }
} }

View File

@ -5,6 +5,8 @@ import javax.sql.DataSource;
import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration; import org.springframework.context.annotation.Configuration;
import org.springframework.jdbc.datasource.DriverManagerDataSource; import org.springframework.jdbc.datasource.DriverManagerDataSource;
import org.springframework.web.servlet.config.annotation.CorsRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;
@Configuration @Configuration
public class JdbcConfig { public class JdbcConfig {
@ -20,4 +22,15 @@ public class JdbcConfig {
return source; return source;
} }
@Bean
public WebMvcConfigurer corsConfigurer() {
return new WebMvcConfigurer() {
@Override
public void addCorsMappings(CorsRegistry registry) {
registry.addMapping("/greeting-javaconfig").allowedOrigins("*");
}
};
}
} }

View File

@ -8,6 +8,7 @@
"name": "clyde", "name": "clyde",
"version": "0.0.0", "version": "0.0.0",
"dependencies": { "dependencies": {
"toastify-js": "^1.12.0",
"vue": "^3.4.15" "vue": "^3.4.15"
}, },
"devDependencies": { "devDependencies": {
@ -2167,6 +2168,11 @@
"node": ">=14.0.0" "node": ">=14.0.0"
} }
}, },
"node_modules/toastify-js": {
"version": "1.12.0",
"resolved": "https://registry.npmjs.org/toastify-js/-/toastify-js-1.12.0.tgz",
"integrity": "sha512-HeMHCO9yLPvP9k0apGSdPUWrUbLnxUKNFzgUoZp1PHCLploIX/4DSQ7V8H25ef+h4iO9n0he7ImfcndnN6nDrQ=="
},
"node_modules/tough-cookie": { "node_modules/tough-cookie": {
"version": "4.1.3", "version": "4.1.3",
"resolved": "https://registry.npmjs.org/tough-cookie/-/tough-cookie-4.1.3.tgz", "resolved": "https://registry.npmjs.org/tough-cookie/-/tough-cookie-4.1.3.tgz",

View File

@ -10,6 +10,7 @@
"test:unit": "vitest" "test:unit": "vitest"
}, },
"dependencies": { "dependencies": {
"toastify-js": "^1.12.0",
"vue": "^3.4.15" "vue": "^3.4.15"
}, },
"devDependencies": { "devDependencies": {

View File

@ -1,5 +1,10 @@
<script setup> <script setup>
import 'https://kit.fontawesome.com/fb3bbd0a95.js' import 'https://kit.fontawesome.com/fb3bbd0a95.js'
import Toastify from 'toastify-js'
import { ref } from 'vue'
const test = ref();
fetch("http://localhost:8080/ping").then((e) => { return e.json() }).then(e => console.log(e) );
</script> </script>
<template> <template>