Skip to main content

Mini Project: Cross-Origin Rules for a Public API

Learn Mini Project: Cross-Origin Rules for a Public API (CORS, Spring MVC) with worked examples, diagrams and interview questions. Free on JavaSchoolLab.

Mini Real-Time Project: Cross-Origin Rules for a Public API Problem A front end hosted on https://shop.example.com calls an API on another domain. Browsers block this unless the API says it is allowed. Configure CORS so that only trusted sites may call, and show the preflight handshake. Requirements Allow one trusted origin globally for /api/**. Allow a second origin on a single controller with @CrossOrigin. Show the preflight (OPTIONS) response headers. Show an untrusted origin being rejected. Show that a same-origin request needs no CORS headers. Concepts Used CORS preflight OPTIONS request...

More lessons in CORS