Browser-sync: BrowserSync willnot follow links to pages with "php" extension; prompts to download; proxy server

Created on 25 Jun 2016  路  4Comments  路  Source: BrowserSync/browser-sync

Issue details

I am running BrowserSync as a proxy server for local web servers.
Attempting to follow a link to a webpage with a ".php" extension causes a download modal dialog.

Steps to reproduce/test case

Run the script node live.js (see below).
Once site has loaded in browser, click link.

Please specify which version of Browsersync, node and npm you're running

  • Browsersync [ 2.13.0 ]
  • Node [ 4.4.3 ]
  • Npm [ 2.15.3 ]

    Affected platforms

  • [ ] linux

  • [ ] windows
  • [x ] OS X
  • [ ] freebsd
  • [ ] solaris
  • [ ] other _(please specify which)_

    Browsersync use-case

  • [x ] API

  • [ ] Gulp
  • [ ] Grunt
  • [ ] CLI

    If CLI, please paste the entire command below

{cli command here}

for all other use-cases, (gulp, grunt etc), please show us exactly how you're using Browsersync

/**
 * Require Browsersync
 */
var requireg = require('requireg');
var bs = requireg('browser-sync').create();

/**
 * Run Browsersync with server config
 */

bs.init({
    proxy: "localhost:8081",
    reloadOnRestart: false,
    online: false,
    serveStatic: ["../wwwroot"],
    files: ["../wwwroot"]
});

Most helpful comment

same issue with downloading php files. @stefanomonteiro did you find a resolution?

All 4 comments

Hello, looks like you are using browser sync in proxy mode, does php work on localhost:8081?

Same here. I'm using browser-sync 2.18.13, npm 5.1.0 and node 8.0.0. I'm using the CLI:

browser-sync start --proxy 'https://localhost' --serveStatic 'src' --files 'src'

The reason for the download window is the wrong content-type returned by browser-sync's proxy:

  • my upstream apache returns Content-Type: text/html; charset=UTF-8 when requesting a .php file.
  • However, the proxy returns Content-Type: application/octet-stream which causes the browser to open the download window.

I would assume that the proxy just passes the content-type on.
By the way: the other HTTP headers are also not correctly returned by the proxy.

Any resolution for this case? I am having the same issue two years later.

same issue with downloading php files. @stefanomonteiro did you find a resolution?

Was this page helpful?
0 / 5 - 0 ratings

Related issues

ngryman picture ngryman  路  3Comments

codeofsumit picture codeofsumit  路  3Comments

npearson72 picture npearson72  路  3Comments

jitendravyas picture jitendravyas  路  4Comments

ericmorand picture ericmorand  路  3Comments