Skip to content

Spring boot Microservices with Global CORS configuration support

Notifications You must be signed in to change notification settings

karthikns2/Spring_Micorservices_CORS

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

6 Commits
 
 
 
 

Repository files navigation

Spring_Microservices_CORS

CORS - Cross-Origin Resource Sharing (CORS) is a W3C specification implemented by most browsers that allows you to specify what kind of cross domain requests are authorized rather than using less secure and less powerful workarounds. List of permissible origins to access the API's can be added.

This Spring Boot project explains how to Configure the Global CORS in a Micro-services architecture

There are two ways to achieve this -

  1. Configure via Application properties/yaml file -- Limitations is Runtime changes can't be done.
  2. Spring cloud configuration properties via Bootstrap file and Runtime properties changes can be done without buildind & redeploying the application.

By default global configuration enables the following values:

Allowed-Origins - All origins. Allowed-Headers - All headers. Allowed-Methods - GET, HEAD, and POST methods. Allowed-Credentials - is not enabled by default since that establishes a trust level that exposes sensitive user-specific information such as cookies and CSRF tokens, and should only be used where appropriate.

maxAge is set to 30 minutes.

This example illustrates how to configure via application properties/yml file.

About

Spring boot Microservices with Global CORS configuration support

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages