Warning: This guide contains system-level modifications. Some steps are irreversible or can render your system unbootable. Read every section fully before executing any command. Know what you are doing, or do not proceed.
| # | Section |
|---|
| $.fn.crossDomainRequest = function(url, method, data, fn) { | |
| var self = this; | |
| var receiver = self.attr('src').replace(/\/.*$/, '').replace(/^https?::\/\//, ''); | |
| function get(event) { | |
| if (event.origin.match(receiver)) { | |
| // event.data is response from POST | |
| fn(event.data); | |
| } | |
| } | |
| if (window.addEventListener){ |
| var http = require('http'); | |
| var httpProxy = require('http-proxy'); | |
| var proxy = httpProxy.createProxyServer(); | |
| http.createServer(function(req, res){ | |
| if(/^\/api/.test(req.url)){ | |
| req.url = req.url.replace(/^\/api/, ""); | |
| proxy.web(req, res, {target:'http://localhost:7889'}); | |
| } else { |