Issue 1:
Bug report

Describe the bug

When I'm deploying a nextjs app, I've got the character / appended at the end of the path, which is not appearing during development.

To Reproduce

in pages folder, create a component (such as home.js)

In development, path will be /home if following structure pages/home.js

Once deployed (e.g. : netlify), path will be /home/

System information

OS: macOS 10.13

Browser: chrome

Version of Next.js: 7.0.2

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.