package com.google.rolecall.config;

import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.Profile;
import org.springframework.core.env.Environment;
import org.springframework.web.servlet.config.annotation.CorsRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;

@Profile("dev")
@Configuration
public class WebConfig implements WebMvcConfigurer {

  private final Environment env;

  @Override
  public void addCorsMappings(CorsRegistry registry) {
      String allowedOrigin = env.getProperty("rolecall.frontend.url");
      
      registry.addMapping("/api/**").allowedOrigins(allowedOrigin)
          .allowedMethods("GET", "POST", "PATCH", "DELETE");
      registry.addMapping("/logout").allowedOrigins(allowedOrigin)
          .allowedMethods("GET", "POST", "PATCH", "DELETE");
  }

  public WebConfig(Environment env) {
    this.env = env;
  }
}

@@ -638,12 +638,8 @@
 g(%22/
-api/
 **%22)
@@ -689,118 +689,24 @@
 llow
-edMethods(%22GET%22, %22POST%22, %22PATCH%22, %22DELETE%22);%0A      registry.addMapping(%22/logout%22).allowedOrigins(allowedOrigin
+Credentials(true
 )%0A  

Allow credentials