title: Browser automatically downloads PHP files
body: <p>i'm reading the book 'Node.js for PHP Developers'. I have created a NodeJS Web Server and it receives requests and gives response too. But whenever I access a PHP file to reroute it to a JS file (requirement it is), my browser automatically downloads the PHP file.</p>
  
  <p>Here's my JS code, according to which it also downloads JS files(e.g. when I access localhost:1337/first.njs)</p>
  
  <pre><code>var http = require('http');
  var url = require('url');
  var file = require('./first.njs');
  
  http.createServer(function(req, res) {
  if(url.parse(req.url).pathname == 'first.php')
      file.serve(req, res);
  else
      res.end('The file doesn\'t exist');
  }).listen(1337, '127.0.0.1');
  
  console.log('Server is running on 1337');
  </code></pre>
  
  <p>And here's my PHP file if it matters</p>
  
  <pre><code>&lt;?php
    echo "ASD";
  ?&gt;
  </code></pre>
  
  <p>I know it feels like a really dumb question, but I can't figure out why that happens.</p>
  
  <p>Browsers tested: Chrome and Firefox.</p>
  
  <p><b>UPDATE</b>
  Couldn't figure out the exact problem neither could replicate the problem - but this is my latest code if anyone wants to reroute a requested PHP file to a JS file and serve it(the JS file)</p>
  
  <pre><code>var http = require('http');
  var url = require('url');
  var file = require('./first.njs');
  
  http.createServer(function(req, res) {
  if(url.parse(req.url).pathname == '/first.php')
      file.serve(req, res);
  else
      res.end('File not found');
  }).listen(1337, '127.0.0.1');
  
  console.log('Server is running on 1337');
  </code></pre>