diff --git a/simpleblog/front/src/views/WriteView.vue b/simpleblog/front/src/views/WriteView.vue index 7239d92e..48b11a79 100644 --- a/simpleblog/front/src/views/WriteView.vue +++ b/simpleblog/front/src/views/WriteView.vue @@ -7,8 +7,10 @@ const content = ref(""); const write = () => { - console.log("hi") - axios.get("http://localhost:8080"); + axios.post("/api/posts", { + title: title.value, + content: content.value, + }); } diff --git a/simpleblog/front/vite.config.ts b/simpleblog/front/vite.config.ts index b20d9484..bbd2ff1b 100644 --- a/simpleblog/front/vite.config.ts +++ b/simpleblog/front/vite.config.ts @@ -12,4 +12,13 @@ export default defineConfig({ "@": fileURLToPath(new URL("./src", import.meta.url)), }, }, + server: { + proxy: { + "/api": { + target: "http://localhost:8080", + rewrite: (path) => path.replace(/^\/api/, ""), + }, + + } + } }); diff --git a/simpleblog/src/main/java/com/example/simpleblog/config/WebConfig.java b/simpleblog/src/main/java/com/example/simpleblog/config/WebConfig.java new file mode 100644 index 00000000..027f0f6b --- /dev/null +++ b/simpleblog/src/main/java/com/example/simpleblog/config/WebConfig.java @@ -0,0 +1,15 @@ +//package com.example.simpleblog.config; +// +//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 WebConfig implements WebMvcConfigurer { +// +// @Override +// public void addCorsMappings(CorsRegistry registry) { +// registry.addMapping("/**") +// .allowedOrigins("http://localhost:5173"); +// } +//}