I have get requests working, but post requests to the server are not working
I'll keep it short. I'm using Spring Cloud From Angular I send a request to Gateway(8082) and it redirects to the microservice I need.
What I've tried so far:
@CrossOrigin(origins = "*")
I put it over each controllerWriting a config class. I've been overhauling this config as much as I can.
import org.springframework.context.annotation.Configuration; import org.springframework.web.servlet.config.annotation.CorsRegistry; import org.springframework.web.servlet.config.annotation.EnableWebMvc; import org.springframework.web.servlet.config.annotation.WebMvcConfigurer; @Configuration @EnableWebMvc public class WebConfig implements WebMvcConfigurer { @Override public void addCorsMappings(CorsRegistry registry) { registry.addMapping("/auth/user/**") // Specificare il percorso dell'API .allowedOrigins("http://localhost:4200") // Fonte autorizzata. .allowedOrigins("http://localhost:8202") // Fonte autorizzata. .allowedMethods("GET") // Metodi autorizzati .allowedMethods("POST") // Metodi autorizzati .allowedMethods("PUT") // Metodi autorizzati .allowedMethods("DELETE") // Metodi autorizzati .allowCredentials(true); // Consentire l'invio di cookie e intestazioni di autorizzazione } }
Created the proxy.conf.ts file:
{ "/finance/*": { "target": "http://localhost:8082", "secure": false }, "/auth/*": { "target": "http://localhost:8082", "secure": false } }
But still post requests through postman I can send, but through angular I can't:(