Posted By

chrisaiv on 07/07/12


Tagged

js nodejs


Versions (?)

NodeJS: Delivering a crossdomain.xml file using Express.JS


 / Published in: JavaScript
 

There are many ways to deliver a crossdomain.xml file through NodeJS or Express.js. Here is one solution

  1. app.get( "/crossdomain.xml", onCrossDomainHandler )
  2. function onCrossDomainHandler( req, res ) {
  3. var xml = '<?xml version="1.0"?>\n<!DOCTYPE cross-domain-policy SYSTEM' +
  4. ' "http://www.macromedia.com/xml/dtds/cross-domain-policy.dtd">\n<cross-domain-policy>\n';
  5. xml += '<allow-access-from domain="*" to-ports="*"/>\n';
  6. xml += '</cross-domain-policy>\n';
  7.  
  8. req.setEncoding('utf8');
  9. res.writeHead( 200, {'Content-Type': 'text/xml'} );
  10. res.end( xml );
  11. }

Report this snippet  

You need to login to post a comment.