Skip to content

Custom 404.html in publish folder is ignored #1158

@FinnWoelm

Description

@FinnWoelm

Hey Netlify ❤️,

As I've said before, thanks for all your work! 🙌 Here is a tiny issue. I'm going to submit a corresponding PR in a few minutes.

Describe the bug

In Netlify, you can set a custom 404 page by putting a 404.html file into the publish folder (e.g., public or whatever is specified in netlify.toml). This custom 404 page is not picked up by netlify dev. For it to work in netlify dev, the custom 404.html file must be in the root folder. This is inconsistent with Netlify in production.

To Reproduce

git clone https://github.com/FinnWoelm/netlify-404
cd netlify-404
netlify dev

Visit http://localhost:8888/this-file-does-not-exist and see Not found instead of the custom 404.html page:

Screenshot_2020-08-27 Screenshot

Configuration

  • If possible, please copy/paste below your netlify.toml.
[build]
  publish     = "public"
  • Please enter the following command in a terminal and copy/paste its output:
  System:
    OS: Linux 5.4 Ubuntu 20.04.1 LTS (Focal Fossa)
    CPU: (4) x64 Intel(R) Core(TM) i5-5200U CPU @ 2.20GHz
    Memory: 256.93 MB / 7.68 GB
    Container: Yes
    Shell: 5.0.17 - /bin/bash
  Binaries:
    Node: 12.14.1 - ~/.nvm/versions/node/v12.14.1/bin/node
    Yarn: 1.22.5 - /usr/bin/yarn
    npm: 6.14.7 - ~/.nvm/versions/node/v12.14.1/bin/npm
    Watchman: 4.7.0 - /usr/local/bin/watchman
  npmGlobalPackages:
    netlify-cli: 2.59.1

Expected behavior

My custom error page should be visible, like it is on Netlify when visiting https://netlify-404.netlify.app/this-file-does-not-exist:

Screenshot_2020-08-27 404 - Not Found

Additional context

Working on a PR right now. This issue is just here for context.

The PR should only be a single change:

notFound: '404.html',

The 404.html needs to be prepended by the public folder path, similar to here:

const maybe404Page = path.resolve(publicFolder, '404.html')

Will let you know if I run into any issues with the PR! 👍

Metadata

Metadata

Assignees

No one assigned

    Labels

    type: bugcode to address defects in shipped code

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions