Frontend Development 13 min read

Cross-Origin and Same-Origin Strategies: JSONP, CORS, Proxy, Nginx, WebSocket, postMessage, and document.domain

This article explains the concepts of cross‑origin and same‑origin policies, and demonstrates multiple solutions—including JSONP, CORS headers, proxy servers, Nginx configuration, WebSocket communication, postMessage, and document.domain—providing both front‑end and back‑end code examples for each method.

Rare Earth Juejin Tech Community
Rare Earth Juejin Tech Community
Rare Earth Juejin Tech Community
Cross-Origin and Same-Origin Strategies: JSONP, CORS, Proxy, Nginx, WebSocket, postMessage, and document.domain

Home

const obj = {name: 'midsummer', age: 18}; document.getElementById('frame').onload = function() { this.contentWindow.postMessage(obj, 'http://127.0.0.1:8080'); window.onmessage = e => console.log(e.data); };

proxyWebSocketCORSCross-OriginJSONPpostMessagesame-origin
Rare Earth Juejin Tech Community
Written by

Rare Earth Juejin Tech Community

Juejin, a tech community that helps developers grow.

0 followers
Reader feedback

How this landed with the community

login Sign in to like

Rate this article

Was this worth your time?

Sign in to rate
Discussion

0 Comments

Thoughtful readers leave field notes, pushback, and hard-won operational detail here.