Issue 1:
Feature request

Is your feature request related to a problem? Please describe.

I created a account folder in the pages folder. And in this account folder, I added a index.js file.

I would like to reach this page through /account/, but I get a 404 error. It is only reachable through /account.

Describe the solution you'd like

When I create a folder, I would like to be able to reach it with a trailing slash.

Issue 2:
trailing slash in link for legit page works for client side navigation but leads to not found bundle and 404 on hard refresh (ssr)

Bug report

Describe the bug

let me know if title needs further clarification.

all relevant issues has been closed with reasoning that its been fixed in 6-canary (I believe it is not) or by improved serve (which is true only in perhaps production static export).

I'm rewriting my existing blog to next.js and i previously used trailing slashes. Latest serve can help with it once i build my next.js powered blog. But in order to fix dev env i need either to get rid of trailing slashes and utilize 301 Moved Permanently in prod; or live with broken trailing slash support in dev.

To Reproduce

Here is minimal reproducible case (link to repro repo is below snippet):

// pages/index.js
import Link from "next/link";

export default () => (
<Link href="/about/">
<a>About</a>
</Link>
);

// pages/index.js
export default () => "about";

Minimal reproducible repo https://github.com/iamstarkov/next.js-trailing-slash-bug-demo

clone repo git clone https://github.com/iamstarkov/next.js-trailing-slash-bug-demo

change directory cd next.js-trailing-slash-bug-demo

install deps yarn

run dev: yarn dev

open http://localhost:3000/

open devtools' network tab

observe http://localhost:3000/_next/static/development/pages/about.js being 200ed

observe http://localhost:3000/_next/on-demand-entries-ping?page=/about/ being 200ed

observe http://localhost:3000/about/ being 404ed

observe persistent attempts to resolve http://localhost:3000/about/

observe in the terminal Client pings, but there's no entry for page: /about/

refresh the page

observe 404 page.

remove trailing slash in the url or click http://localhost:3000/about

observe page being 200ed

to ensure error persistence repeat steps 5-15 once.

Expected behavior

/about/ shouldnt be resolved as 404 not found

/about/ should be resolved as 200 ok

Server should not print Client pings, but there's no entry for page: /about/

both /about and /about/ should work the same way

Screenshots

N/A

System information

OS: macOS High Sierra 10.13.6 (17G65)

Browser (should not matter, but can repro'ed in chrome 69.0.3497.100 and safari Version 12.0 (13606.2.11) (was the same for safari 11)

Version of Next.js: 7.0.0 (could repro on 5.x and 6.x)

Additional context

Add any other context about the problem here.

If you change this code in https://github.com/zeit/next.js/blob/459c1c13d054b37442126889077b7056269eeb35/server/on-demand-entry-handler.js#L242-L249

or node_modules/next/dist/server/on-demand-entry-handler.js locally

const { query } = parse(req.url, true)
const page = normalizePage(query.page)
+ console.log('query.page', query.page);
+ console.log('page', page);
+ console.log('Object.keys(entries)', Object.keys(entries));
const entryInfo = entries[page]

// If there's no entry.
// Then it seems like an weird issue.
if (!entryInfo) {
const message = `Client pings, but there's no entry for page: ${page}`

and restart next dev and open http://localhost:3000/ and click about link then:

for /about

query.page /about
page /about
Object.keys(entries) [ '/', '/about' ]

for /about/:

query.page /about/
page /about/
Object.keys(entries) [ '/', '/about' ]
Client pings, but there's no entry for page: /about/

I think the problem (at least part of it) is in inability of onDemandEntryHandler's middleware to find page in entries if page has trailing slash.

I hope my 2 hours of investigation and preparation can help with fixing this issue.