StudentLoanManagement
CorsConfig.java
Go to the documentation of this file.
1package com.student_loan.config;
2
3// TODO Esta clase hay que cambiarla
4
5import org.springframework.context.annotation.Bean;
6import org.springframework.context.annotation.Configuration;
7import org.springframework.web.servlet.config.annotation.CorsRegistry;
8import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;
9
10@Configuration
11public class CorsConfig {
12
13 @Bean
14 public WebMvcConfigurer corsConfigurer() {
15 return new WebMvcConfigurer() {
16 @Override
17 public void addCorsMappings(CorsRegistry registry) {
18 registry.addMapping("/**") // Aplica a todas las rutas
19 .allowedOrigins("http://localhost:3000") // Permite solo el frontend
20 .allowedMethods("GET", "POST", "PUT", "DELETE", "OPTIONS") // Métodos permitidos
21 .allowedHeaders("*") // Permitir todos los headers
22 .allowCredentials(true); // Permitir cookies/sesiones
23 }
24 };
25 }
26}