Summary
We have learned some important ways of applying CORS in Node.js. Let us have a quick recap of what we have learned.
Node.js provides a web server built with JavaScript, and can be combined with many other JS frameworks as the application server.
Although some frameworks have specific syntax for implementing CORS, they all follow the CORS
specification by specifying the allowed origin(s) and method(s). More robust frameworks allow custom headers, such as Content-Type
and preflight
, when required for complex CORS requests.
JavaScript frameworks may depend on the jQuery XHR
object, which must be configured properly to allow cross-origin requests.
JavaScript frameworks are evolving rapidly. The examples here may become outdated. Always refer to the project documentation for up-to-date information.
With knowledge of the CORS specification, you may create your own techniques using JavaScript based on these examples, depending on the specific needs of your application.
Now you know most of the...