Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

browser-sync-client script 404 when using <base> tag #437

Closed
LukeAskew opened this issue Feb 10, 2015 · 10 comments · May be fixed by tobybellwood/govstrap#4
Closed

browser-sync-client script 404 when using <base> tag #437

LukeAskew opened this issue Feb 10, 2015 · 10 comments · May be fixed by tobybellwood/govstrap#4

Comments

@LukeAskew
Copy link

When I include a <base href="http://www.website.com/" /> tag, the browser-sync-client.1.9.1.js makes a request to that base url rather than localhost, causing a 404.

Is it possible to use <base> with BrowserSync?

Running 1.9.0.

@shakyShane
Copy link
Contributor

Hi - I'm not entirely sure what you mean.

You could provide a small, reduced test-case html page showing me exactly what you mean?

@LukeAskew
Copy link
Author

Sure.

<!doctype html>
<html>
<head>
    <base href="http://www.google.com/" />
</head>
<body>

    <h1>Hello World!</h1>
    <img src="images/srpr/logo11w.png" alt="Google">

</body>
</html>

The base tag throws off the browse-sync-client-x.x.x.js reference; it tries to pull from the base url, e.g. http://www.google.com/browser-sync/browser-sync-client.1.9.1.js

@shakyShane
Copy link
Contributor

Fixed in browser-sync@2.1.2

@LukeAskew
Copy link
Author

Confirmed 👍

@shakyShane
Copy link
Contributor

tumblr_m0osrrhqmk1qzcv7no4_250

@shakyShane
Copy link
Contributor

OUCH!

This actually caused a huge regression in BrowserSync and has been reverted in 2.2.0

To mimic the fix though, you can easily use this option to get the same result.

scriptPath: function (path, port, options) {
    return options.get("absolute");
}

http://www.browsersync.io/docs/options/#option-scriptPath

@mj1618
Copy link

mj1618 commented Oct 21, 2016

Yes I get the same issue in 2.2.0

@evolutionxbox
Copy link

Is there a way to set scriptPath using the cli?

@evolutionxbox
Copy link

evolutionxbox commented Mar 14, 2017

@shakyShane Can we re-open this issue? It is still a problem.

@majster
Copy link

majster commented Jul 18, 2017

@evolutionxbox just use routes property and rewrite context served

browserSync.init({
    server: {
        baseDir: '.',
        port: 3000,
        middleware: [jsonPlaceholderProxy1, jsonPlaceholderProxy2],
        routes: {
            "/my-base-path": ""
        }
    },
    startPath: '.',
    open: false,
    injectChanges: true,
    files: ['**/*.html', '**/*.js', '**/*.css'],
    watchTask: true
});

# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

5 participants