Skip to content
Snippets Groups Projects
Commit c086cfcc authored by Byron Biggs's avatar Byron Biggs
Browse files

Added WebConfig file (for api)

parent 65cbd9b7
No related branches found
No related tags found
No related merge requests found
package com.example.demo.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("/api/**")
.allowedOrigins("*") // Allow any origin - replace with specific origins in production
.allowedMethods("GET", "POST", "PUT", "DELETE", "OPTIONS")
.allowedHeaders("*")
.maxAge(3600); // 1 hour cache for CORS preflight requests
}
}
\ No newline at end of file
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment