Skip to content
New issue

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

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

Already on GitHub? Sign in to your account

404 page #537

Open
soniktrooth opened this issue Jan 2, 2018 · 1 comment
Open

404 page #537

soniktrooth opened this issue Jan 2, 2018 · 1 comment

Comments

@soniktrooth
Copy link
Contributor

We should add the ability to gracefully handle 404 pages.

Here is an exampe of how to do it with Browsersync:

'use strict';

const content_404 = fs.readFileSync(path.join(__dirname, '404.html'));

const browserSync = require("browser-sync").create();

browserSync.init({
    files: ["app/css/*.css"],
    server: {
        baseDir: "app"
    }
}, (err, bs) => {
    bs.addMiddleware("*", (req, res) => {
        // Provides the 404 content without redirect.
        res.write(content_404);
        res.end();
    });
});

Stolen gracefully from BrowserSync/browser-sync#1398

@RobLoach RobLoach removed their assignment Feb 27, 2023
@jeffschwartz
Copy link

But what about the CLI, how would that work?

It'd be awesome to have a command line option like --pageNotFound "./404.html", which would avoid the need to have to use a script. While the above works for those who are already scripting, many would lose the benefit of the CLI just because they need to handle 404.

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

No branches or pull requests

3 participants