5

I have an application on heroku that return some oauth tokens. In my spring boot application I have used WebMvcConfigurerAdapter that gets a list of origin from database.

return new WebMvcConfigurerAdapter() {
            @Override
            public void addCorsMappings(CorsRegistry registry) {
                String[] origins = new String[originList.size()];
                origins = originList.toArray(origins);
                registry.addMapping("/getToken").allowedHeaders("Allow-access-control-origin").allowedOrigins(origins);
            }
        };

Now, In the heroku app there is a text area where a user can update their domain name, user can add multiple domain. If a user wants to add multiple domain then the domain will be separated by comma and directly put in database. Later In the corsConfigurer() method i parse the domain names and get all the domain and white list it.

Everytime a user updates or add a domain then the server restarts to include all the changes.

In spring or Java EE, Can i make cors registry to dynamically add updated or newly inserted origin in their whitelist registry without restarting the server.

(I searched on SO for this question but did not find any accepted answer)

Thanks

lambad
  • 1,046
  • 10
  • 21
  • nice question interested to know the outcomes and suggestions – kakabali Mar 30 '18 at 05:14
  • Related: https://stackoverflow.com/questions/19959114/is-there-a-way-to-dynamically-update-a-list-of-allowed-origins-in-web-api-cors – jub0bs Jan 13 '23 at 12:20

0 Answers0