{"id":16039560,"url":"https://github.com/iruzhnikov/spring-cors-properties","last_synced_at":"2026-02-27T11:44:07.159Z","repository":{"id":37828177,"uuid":"470045719","full_name":"IRuzhnikov/spring-cors-properties","owner":"IRuzhnikov","description":"CORS configuration from properties file","archived":false,"fork":false,"pushed_at":"2023-09-20T04:23:37.000Z","size":216,"stargazers_count":0,"open_issues_count":18,"forks_count":1,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-04-02T09:14:43.889Z","etag":null,"topics":["java","spring","spring-boot","spring-security"],"latest_commit_sha":null,"homepage":"","language":"Java","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/IRuzhnikov.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2022-03-15T07:14:39.000Z","updated_at":"2022-12-23T12:25:15.000Z","dependencies_parsed_at":"2024-10-27T17:18:50.306Z","dependency_job_id":null,"html_url":"https://github.com/IRuzhnikov/spring-cors-properties","commit_stats":null,"previous_names":[],"tags_count":27,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/IRuzhnikov%2Fspring-cors-properties","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/IRuzhnikov%2Fspring-cors-properties/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/IRuzhnikov%2Fspring-cors-properties/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/IRuzhnikov%2Fspring-cors-properties/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/IRuzhnikov","download_url":"https://codeload.github.com/IRuzhnikov/spring-cors-properties/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":246785489,"owners_count":20833497,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["java","spring","spring-boot","spring-security"],"created_at":"2024-10-08T23:05:29.156Z","updated_at":"2026-02-27T11:44:07.089Z","avatar_url":"https://github.com/IRuzhnikov.png","language":"Java","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Description\n\nThis library enables the CORS configuration in application property\nfiles such as application.properties / application.yml / cors.yml\nIn general. no coding is required to configure CORS for different\nenvironments of your application. All you need to do is\n\n1. add the feature to your project changing maven / gradle / other build tool config\n2. enable the feature in project property file\n3. configure the CORS in the same or separate property file, that's up to you to decide\n\n# How to add the feature to Spring Boot\n\nTo enable the feature, please add the dependency to your project (navigate to this links):  \n\u003e [![MVC](https://img.shields.io/maven-central/v/io.github.iruzhnikov/spring-webmvc-cors-properties-autoconfigure.svg?label=Maven%20Central:%20Spring%20MVC.\u0026style=flat-square)](https://search.maven.org/search?q=g:%22io.github.iruzhnikov%22%20AND%20a:%22spring-webmvc-cors-properties-autoconfigure%22)  \n\u003e group: _io.github.iruzhnikov_  \n\u003e name: _spring-webmvc-cors-properties-autoconfigure_  \n\n\u003e [![FLUX](https://img.shields.io/maven-central/v/io.github.iruzhnikov/spring-webflux-cors-properties-autoconfigure.svg?label=Maven%20Central:%20Spring%20FLUX\u0026style=flat-square)](https://search.maven.org/search?q=g:%22io.github.iruzhnikov%22%20AND%20a:%22spring-webflux-cors-properties-autoconfigure%22)  \n\u003e group: _io.github.iruzhnikov_  \n\u003e name: _spring-webflux-cors-properties-autoconfigure_\n\n# To enable the feature in Spring Boot project\n\nAdd this property to `application.properties` file for adding reading configuration from different file\n\n`application.properties` file content:\n\n```yml\nspring.config.import: optional:classpath:cors.yml\n```\n\nConfigure the CORS rules in `cors.yml` properties file\n\n`cors.yml` file content:\n\n```yml\nspring:\n  web:\n    cors:\n      enabled: true\n      mappings: #spring.web.cors.mappings.\u003cany_name\u003e.\u003cproperty\u003e: \u003cvalue\u003e\n        anyName: #just any name, just for grouping properties under the same path pattern (not used in internal logic)\n          paths: #ant style path pattern, ATTENTION! not ordered, /** pattern override all other pattern\n            - /path/to/api\n            - /path/to/api/**\n          #allowed-origins: \"*\"\n          allowed-methods: GET #Enable override all defaults! If disabled: a lot more from all the controller methods included from the path pattern matches\n          #allowed-headers: \"*\"\n          #exposed-headers: ('*' - not-supported)\n          #allow-credentials: true\n          allowed-origin-patterns: .*\n          #max-age: PT30M\n```\n\nThe 'anyName' in configuration lets you configure the different groups, e.g. 'path /api' and 'path /api/admin' may\nhave CORS configurations. To make the configurations different, please different sections, e.g. 'anyName: api' and\n'anyName: apiAdmin'.\n\nActually, that's all you need to do basic configuration. The further configs are to let you make tiny\nconfigurations.\n\n\u003e ![](https://img.shields.io/static/v1?label=\u0026message=NOTE\u0026style=flat-square\u0026color=blue)  \n\u003e To specify details of CORS configuration you may use a separate file _cors.yml_ (of course you may use default\n\u003e _application.properties_ file).  \n\u003e [more details about `spring.config.import` in Spring](https://docs.spring.io/spring-cloud-config/docs/current/reference/html/#config-data-import)\n\n\u003e ![](https://img.shields.io/static/v1?label=\u0026message=WARNING\u0026style=flat-square\u0026color=orange)  \n\u003e Don't use this library for CORS configuration for `Spring Actuator`,\n\u003e because this library has self specific config (props name like of _management.*_)  \n\u003e [more details in Spring](https://docs.spring.io/spring-boot/docs/current/reference/html/actuator.html#actuator.endpoints.cors)\n\n\u003e ![](https://img.shields.io/static/v1?label=\u0026message=WARNING\u0026style=flat-square\u0026color=orange)  \n\u003e For application.yml files that contains several 'spring.profiles', please use property file annotation (one line)\n\u003e for `spring.web.cors.enabled`, otherwise spring boot ignores the config line.  \n\u003e [more details in stackoverflow](https://stackoverflow.com/a/35400025)\n\n### Autoconfigure for _allowed-methods_ (GET, POST etc.) by _path_ patterns\n\nIf you like to have the automatic discovery of the _allowed-methods_ in your CORS configuration, please  \nremove _@EnableWebMvc_  in your code.\n\n\u003e ![](https://img.shields.io/static/v1?label=\u0026message=ATTENTION\u0026style=flat-square\u0026color=red)  \n\u003e if you extended corresponding class:\n\u003e ```java\n\u003e //for MVC\n\u003e import org.springframework.webmvc.servlet.config.annotation.WebMvcConfigurationSupport;\n\u003e //for FLUX\n\u003e import org.springframework.web.reactive.config.DelegatingWebFluxConfiguration;\n\u003e ``` \n\u003e\n\u003e please change extended class to next class or open it for learning how to it works  \n\u003e (I mean createRequestMappingHandlerMapping\n\u003e function)\n\u003e\n\u003e ```java\n\u003e //for MVC\n\u003e import io.github.iruzhnikov.webmvc.servlet.CorsPropWebMvcConfigurationSupport;\n\u003e //for FLUX\n\u003e import io.github.iruzhnikov.webflux.servlet.CorsPropWebFluxConfigurationSupport;\n\u003e ``` \n\n# To enable the feature in Spring Framework\n\nYou must register property apply bean\n\n```java\n//for MVC\nimport io.github.iruzhnikov.webmvc.servlet.SpringMvcCorsConfigurer;\n//for FLUX\nimport io.github.iruzhnikov.webflux.servlet.SpringFluxCorsConfigurer;\n```\n\nand you should register autoconfiguration for _allowed-methods_ (not required)\n\n```java\n//for MVC\nimport io.github.iruzhnikov.webmvc.servlet.CorsEndpointHandlerMapping;\n//for FLUX\nimport io.github.iruzhnikov.webflux.servlet.CorsEndpointHandlerMapping;\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Firuzhnikov%2Fspring-cors-properties","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Firuzhnikov%2Fspring-cors-properties","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Firuzhnikov%2Fspring-cors-properties/lists"}