From 042f1db9f835cf742fb4b797d5aa67e9137cff66 Mon Sep 17 00:00:00 2001 From: Jan Klattenhoff Date: Fri, 4 Apr 2025 19:40:33 +0200 Subject: [PATCH] feat: add CORS configuration for backend API --- .../java/de/szut/casino/config/CorsConfig.java | 15 +++++++++++++++ 1 file changed, 15 insertions(+) create mode 100644 backend/src/main/java/de/szut/casino/config/CorsConfig.java diff --git a/backend/src/main/java/de/szut/casino/config/CorsConfig.java b/backend/src/main/java/de/szut/casino/config/CorsConfig.java new file mode 100644 index 0000000..bb86099 --- /dev/null +++ b/backend/src/main/java/de/szut/casino/config/CorsConfig.java @@ -0,0 +1,15 @@ +package de.szut.casino.config; + +import org.springframework.web.servlet.config.annotation.CorsRegistry; +import org.springframework.web.servlet.config.annotation.WebMvcConfigurer; + +public class CorsConfig implements WebMvcConfigurer { + public void addCorsMappings(CorsRegistry registry) { + registry.addMapping("/**") + .allowedOrigins("http://localhost:4200", "http://192.168.176.120:4200") + .allowedMethods("GET", "POST", "PUT", "DELETE", "OPTIONS") + .allowedHeaders("*") + .allowCredentials(true) + .maxAge(3600); + } +}