0

I am facing below issue while integrating front end code with back end in test server.

Access to fetch at 'https://jdapi-dev.xxxx.tech/api/v1/userManagement/jdUser/JD2343/active' from origin 'https://jdfront-test.heptagon.tech' has been blocked by CORS policy: Response to preflight request doesn't pass access control check: It does not have HTTP ok status. polyfills.52acc7235a996477c95c.js:1 PUT https://jdapi-dev.xxxxx.tech/api/v1/userManagement/jdUser/JD2343/active 504 (Gateway Timeout)

Below are the steps I tried to fix the issue

  1. allow cors in the controller level
  2. allow globally
  3. allow cors with '*'
  4. allow cors with localhost and test server domain
  5. removed all other securities
  6. Server team did some configuration in nginx side
  7. Previously I was able to replicate in local, but now it is working in local but still issue in test

Below is the configuration that I am using

@Configuration
@EnableWebMvc
public class WebConfig implements WebMvcConfigurer {
    @Override
    public void addCorsMappings(CorsRegistry registry) {
        registry.addMapping("/**").allowedOrigins("*").allowedMethods("PUT", "GET", "DELETE", "OPTIONS", "PATCH","POST");
    }
}

Can someone help me for this issue?

Thanks,

Anjana
  • 11
  • 1
  • 1
  • 2
  • If it’s working locally but not in the test server - I would try to hit your application WITHOUT Nginx involved so you can figure out where the hiccup is occurring. – Alexander Katsenelenbogen May 26 '21 at 11:21
  • Hitting the application without Nginx, do you mean without using webserver? or calling the backend api directly? – Anjana May 26 '21 at 14:41
  • "Server team did some configuration in nginx side" -> I imagine that your test server has an nginx proxy in front of your backend application, is that correct? If that is the case, ask them to expose the application port directly instead of having to make a request through nginx. Just a bit of trouble shooting.... – Alexander Katsenelenbogen May 26 '21 at 20:16

0 Answers0