Comments (8)
How are you using CORS Anywhere?
from cors-anywhere.
I'm using CORS Anywhere for a flash video player, and flash player request 'crossdomain.xml' on root of domain.
I try put crossdomain.xml on my serve but when i access via http://host:port/crossdomain.xml it show 404 error.
So, can i do that with CORS Anywhere ? Where i can put 'crossdomain.xml' file ?
from cors-anywhere.
I just hack to your code and add:
if (location.host === 'crossdomain.xml') { res.writeHead(200, {'Content-Type': 'application/xml'}); var xmll = ''; res.end(xmll); return; }
Run ok, but this is not legit, can you have any idea?
from cors-anywhere.
You can simply create a CORS Anywhere server without listening on a port, and then create another HTTP server that handles requests to /crossdomain.xml and otherwise forwards the request to CORS Anywhere.
For example:
var cors_proxy = require('cors-anywhere').createServer({
requireHeader: ['origin', 'x-requested-with'],
removeHeaders: [
'cookie',
'cookie2',
],
// See README.md for other options
});
var fs = require('fs');
require('http').createServer(function(req, res) {
if (req.url === '/crossdomain.xml') {
fs.createReadStream('crossdomain.xml').pipe(res);
return;
}
// Let the server handle it
cors_proxy.emit('request', req, res);
}).listen(8080); // Listen on port 8080.
Reading the file again on every acces of crossdomain.xml is not quite efficient, I recommend reading the caching the contents of the file if possible.
Also note that the above code handles http://example.com:8080/crossdomain.xml
but not http://example.com:8080/crossdomain.xml?some=value
because it looks for an exact match. If you want to allow any prefix to be handled, use req.url.startsWith('/crossdomain.xml')
instead (modern Node.js versions only) or req.url.lastIndexOf('/crossdomain.xml', 0) === 0
(any Node.js version).
from cors-anywhere.
Thank you so much for your time !
Closing ...
from cors-anywhere.
Hello,
I try your code, but it show error:
TypeError: cors_proxy.emit is not a function
from cors-anywhere.
I've edited the snippet, and changed
var cors_proxy = require('cors-anywhere');
cors_proxy.createServer(...);
to
var cors_proxy = require('cors-anywhere').createServer(...);
from cors-anywhere.
Its woking, thank you.
from cors-anywhere.
Related Issues (20)
- Does not work in Deno (TypeError on every request) HOT 1
- 400 Bad Request HOT 1
- Update HTTP-Proxy to 1.18.1 to resolve https://github.com/advisories/GHSA-6x33-pw7p-hmpq HOT 1
- Redirects ruining GET parameters using axios HOT 2
- how to block specific final link not origin
- cors-anywhere doesn't work with youtube m3u8 files HOT 1
- Error creating app on Heroku website HOT 2
- API domain name resolution problem HOT 1
- performance problem, cors-anywhere doesn't use outbound HTTP keep-alive HOT 1
- s anywhere
- Question about whitelisting HOT 1
- getting an Uncaught (in promise) SyntaxError HOT 1
- Authorization error HOT 1
- Whitelisting subdomain doesn't work as expected
- see the CI test #271 #273
- cors anywhere not working on vercel HOT 1
- add option to add auth header for sites like reddit HOT 1
- Siteye kurulum
- live radio use case: Missing required request header. Must specify one of: origin,x-requested-with HOT 4
- Not found because of proxy error: AggregateError
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from cors-anywhere.