language
stringclasses
1 value
owner
stringlengths
2
15
repo
stringlengths
2
21
sha
stringlengths
45
45
message
stringlengths
7
36.3k
path
stringlengths
1
199
patch
stringlengths
15
102k
is_multipart
bool
2 classes
Other
vercel
next.js
455d16419fe07322188a60f6f6abba82159757a6.json
Fix some casing of "On-Demand ISR" (#37892)
docs/api-reference/data-fetching/get-static-paths.md
@@ -10,7 +10,7 @@ description: API reference for `getStaticPaths`. Learn how to fetch data and gen | Version | Changes | | ------- | ------- | -| `v12.1.0` | [On-demand Incremental Static Regeneration](/docs/basic-features/data-fetching/incremental-static-regeneration.md#on-demand-revalidation-beta) added (Beta). |...
true
Other
vercel
next.js
455d16419fe07322188a60f6f6abba82159757a6.json
Fix some casing of "On-Demand ISR" (#37892)
docs/api-reference/data-fetching/get-static-props.md
@@ -10,7 +10,7 @@ description: API reference for `getStaticProps`. Learn how to use `getStaticProp | Version | Changes | | ------- | ------- | -| `v12.1.0` | [On-demand Incremental Static Regeneration](/docs/basic-features/data-fetching/incremental-static-regeneration.md#on-demand-revalidation-beta) added (Beta). |...
true
Other
vercel
next.js
455d16419fe07322188a60f6f6abba82159757a6.json
Fix some casing of "On-Demand ISR" (#37892)
docs/basic-features/data-fetching/incremental-static-regeneration.md
@@ -18,7 +18,7 @@ description: 'Learn how to create or update static pages at runtime with Increme | Version | Changes | | --------- | --------------------------------------------------------------------------------------- | -| `v12.1...
true
Other
vercel
next.js
4898d24f9a370b73e298749aaa3b2b64315cf04d.json
Fix Peer Dependency in React Refresh Utils (#15375) Fixes #15342
packages/react-refresh-utils/package.json
@@ -20,7 +20,7 @@ }, "peerDependencies": { "react-refresh": "0.8.3", - "webpack": "^4|^5" + "webpack": "^4 || ^5" }, "devDependencies": { "react-refresh": "0.8.3"
false
Other
vercel
next.js
fcfbceaa7e80be4adaa70f9bafa66656a4f99a9e.json
Fix cancellation control flow (#15361)
packages/next/next-server/lib/router/router.ts
@@ -22,10 +22,14 @@ import { normalizePathTrailingSlash, } from '../../../client/normalize-trailing-slash' -const ABORTED = Symbol('aborted') - const basePath = (process.env.__NEXT_ROUTER_BASEPATH as string) || '' +function buildCancellationError() { + return Object.assign(new Error('Route Cancelled'), { + ...
true
Other
vercel
next.js
fcfbceaa7e80be4adaa70f9bafa66656a4f99a9e.json
Fix cancellation control flow (#15361)
test/integration/build-output/test/index.test.js
@@ -104,7 +104,7 @@ describe('Build Output', () => { expect(parseFloat(err404FirstLoad) - 63).toBeLessThanOrEqual(0) expect(err404FirstLoad.endsWith('kB')).toBe(true) - expect(parseFloat(sharedByAll) - 59).toBeLessThanOrEqual(0) + expect(parseFloat(sharedByAll) - 59.2).toBeLessThanOrEqual(0) ...
true
Other
vercel
next.js
fcfbceaa7e80be4adaa70f9bafa66656a4f99a9e.json
Fix cancellation control flow (#15361)
test/integration/size-limit/test/index.test.js
@@ -80,7 +80,7 @@ describe('Production response size', () => { ) // These numbers are without gzip compression! - const delta = responseSizesBytes - 273 * 1024 + const delta = responseSizesBytes - 274 * 1024 expect(delta).toBeLessThanOrEqual(1024) // don't increase size more than 1kb expect(...
true
Other
vercel
next.js
d5c1addd645306b79d5031543581c6123c25d0b7.json
Simplify trailing slash regex (#15335)
packages/next/lib/load-custom-routes.ts
@@ -360,13 +360,13 @@ export default async function loadCustomRoutes( if (config.trailingSlash) { redirects.unshift( { - source: '/:path*/:file.:ext/', - destination: '/:path*/:file.:ext', + source: '/:file((?:[^/]+/)*[^/]+\\.\\w+)/', + destination: '/:file', permanen...
true
Other
vercel
next.js
d5c1addd645306b79d5031543581c6123c25d0b7.json
Simplify trailing slash regex (#15335)
test/integration/trailing-slashes/test/index.test.js
@@ -258,13 +258,13 @@ describe('Trailing slashes', () => { expect.objectContaining({ redirects: expect.arrayContaining([ expect.objectContaining({ - source: '/:path*/:file.:ext/', - destination: '/:path*/:file.:ext', + source: '/:file((?:[^/]+/)*[^...
true
Other
vercel
next.js
a11d99390a02c2ced21a7de464e005f8eb5b06d4.json
Stabilize Trailing Slash API (#15331) Closes #15330
docs/api-reference/next.config.js/trailing-slash.md
@@ -4,18 +4,13 @@ description: Configure Next.js pages to resolve with or without a trailing slash # Trailing Slash -> **Warning**: This feature is **experimental and may not work as expected**. -> You must enable the `trailingSlash` experimental option to try it. - By default Next.js will redirect urls with trai...
true
Other
vercel
next.js
a11d99390a02c2ced21a7de464e005f8eb5b06d4.json
Stabilize Trailing Slash API (#15331) Closes #15330
packages/next/build/webpack-config.ts
@@ -839,7 +839,7 @@ export default async function getBaseWebpackConfig( } : {}), 'process.env.__NEXT_TRAILING_SLASH': JSON.stringify( - config.experimental.trailingSlash + config.trailingSlash ), 'process.env.__NEXT_EXPORT_TRAILING_SLASH': JSON.string...
true
Other
vercel
next.js
a11d99390a02c2ced21a7de464e005f8eb5b06d4.json
Stabilize Trailing Slash API (#15331) Closes #15330
packages/next/lib/load-custom-routes.ts
@@ -357,7 +357,7 @@ export default async function loadCustomRoutes( loadRedirects(config), ]) - if (config.experimental.trailingSlash) { + if (config.trailingSlash) { redirects.unshift( { source: '/:path*/:file.:ext/',
true
Other
vercel
next.js
a11d99390a02c2ced21a7de464e005f8eb5b06d4.json
Stabilize Trailing Slash API (#15331) Closes #15330
packages/next/next-server/server/config.ts
@@ -37,8 +37,8 @@ const defaultConfig: { [key: string]: any } = { basePath: '', exportTrailingSlash: false, sassOptions: {}, + trailingSlash: false, experimental: { - trailingSlash: false, cpus: Math.max( 1, (Number(process.env.CIRCLE_NODE_TOTAL) ||
true
Other
vercel
next.js
a11d99390a02c2ced21a7de464e005f8eb5b06d4.json
Stabilize Trailing Slash API (#15331) Closes #15330
test/integration/trailing-slashes/next.config.js
@@ -1,6 +1,4 @@ module.exports = { - experimental: { - // <placeholder> - }, + // trailingSlash: boolean, // basePath: '/docs', }
true
Other
vercel
next.js
a11d99390a02c2ced21a7de464e005f8eb5b06d4.json
Stabilize Trailing Slash API (#15331) Closes #15330
test/integration/trailing-slashes/test/index.test.js
@@ -178,7 +178,7 @@ function testWithTrailingSlash() { describe('Trailing slashes', () => { describe('dev mode, trailingSlash: false', () => { beforeAll(async () => { - nextConfig.replace('// <placeholder>', 'trailingSlash: false') + nextConfig.replace('// trailingSlash: boolean', 'trailingSlash: fal...
true
Other
vercel
next.js
aa62fa7f42971b1c772328b43aeca0233686ada2.json
Add test for main.js in webpack.config.js (#15311) This particular variable was not being read correctly. Added a test for the behavior. Fixes #15261
packages/next/build/webpack-config.ts
@@ -1278,7 +1278,10 @@ export default async function getBaseWebpackConfig( const originalFile = clientEntries[ CLIENT_STATIC_FILES_RUNTIME_MAIN ] as string - entry[CLIENT_STATIC_FILES_RUNTIME_MAIN] = [...['main.js'], originalFile] + entry[CLIENT_STATIC_FILES_RUNTIME_MAIN] = [ ...
true
Other
vercel
next.js
aa62fa7f42971b1c772328b43aeca0233686ada2.json
Add test for main.js in webpack.config.js (#15311) This particular variable was not being read correctly. Added a test for the behavior. Fixes #15261
test/integration/webpack-config-mainjs/client/polyfills.js
@@ -0,0 +1,8 @@ +/* eslint no-extend-native: 0 */ + +// This file runs before React and Next.js core +// This file is loaded for all browsers +// Next.js includes a number of polyfills only for older browsers like IE11 +// Make sure you don't duplicate these in this file +// https://github.com/vercel/next.js/blob/canar...
true
Other
vercel
next.js
aa62fa7f42971b1c772328b43aeca0233686ada2.json
Add test for main.js in webpack.config.js (#15311) This particular variable was not being read correctly. Added a test for the behavior. Fixes #15261
test/integration/webpack-config-mainjs/next.config.js
@@ -0,0 +1,19 @@ +module.exports = { + webpack: function (cfg) { + const originalEntry = cfg.entry + cfg.entry = async () => { + const entries = await originalEntry() + + if ( + entries['main.js'] && + !entries['main.js'].includes('./client/polyfills.js') + ) { + entries['main...
true
Other
vercel
next.js
aa62fa7f42971b1c772328b43aeca0233686ada2.json
Add test for main.js in webpack.config.js (#15311) This particular variable was not being read correctly. Added a test for the behavior. Fixes #15261
test/integration/webpack-config-mainjs/pages/static.js
@@ -0,0 +1,3 @@ +export default function StaticPage() { + return <>Hello World</> +}
true
Other
vercel
next.js
aa62fa7f42971b1c772328b43aeca0233686ada2.json
Add test for main.js in webpack.config.js (#15311) This particular variable was not being read correctly. Added a test for the behavior. Fixes #15261
test/integration/webpack-config-mainjs/test/index.test.js
@@ -0,0 +1,15 @@ +/* eslint-env jest */ + +import { join } from 'path' +import { nextBuild } from 'next-test-utils' + +jest.setTimeout(1000 * 60 * 2) +const appDir = join(__dirname, '../') + +describe('Customized webpack config with main.js', () => { + it('should run correctly with main.js customized', async () => { +...
true
Other
vercel
next.js
3bfc25db9fc6fb21875510d5d9ada9896b87a80c.json
Clarify optional catch all vs catch all routes (#15290) Makes the difference between optional catch all routes and catch all routes clearer. Closes #15229
docs/api-routes/dynamic-api-routes.md
@@ -86,6 +86,8 @@ Catch all routes can be made optional by including the parameter in double brack For example, `pages/api/post/[[...slug]].js` will match `/api/post`, `/api/post/a`, `/api/post/a/b`, and so on. +The main difference between catch all and optional catch all routes is that with optional, the route wi...
true
Other
vercel
next.js
3bfc25db9fc6fb21875510d5d9ada9896b87a80c.json
Clarify optional catch all vs catch all routes (#15290) Makes the difference between optional catch all routes and catch all routes clearer. Closes #15229
docs/routing/dynamic-routes.md
@@ -89,6 +89,8 @@ Catch all routes can be made optional by including the parameter in double brack For example, `pages/post/[[...slug]].js` will match `/post`, `/post/a`, `/post/a/b`, and so on. +The main difference between catch all and optional catch all routes is that with optional, the route without the parame...
true
Other
vercel
next.js
25488f4a03db30cade4d086ba49cd9a50a2ac02e.json
chore(examples): update prismic-javascript to 3.0.1 (#15263) This PR updates Prismic libraries to their latest version. Since the `previewSession` method was deprecated on version 3.0.1 we need to use `getPreviewResolver`. [Docs for in-Website Preview in Javascript ](https://prismic.io/docs/javascript/beyond-the-a...
examples/cms-prismic/package.json
@@ -10,8 +10,8 @@ "classnames": "2.2.6", "date-fns": "2.10.0", "next": "latest", - "prismic-javascript": "2.2.0", - "prismic-reactjs": "1.2.0", + "prismic-javascript": "3.0.1", + "prismic-reactjs": "1.3.1", "react": "^16.13.0", "react-dom": "^16.13.0" },
true
Other
vercel
next.js
25488f4a03db30cade4d086ba49cd9a50a2ac02e.json
chore(examples): update prismic-javascript to 3.0.1 (#15263) This PR updates Prismic libraries to their latest version. Since the `previewSession` method was deprecated on version 3.0.1 we need to use `getPreviewResolver`. [Docs for in-Website Preview in Javascript ](https://prismic.io/docs/javascript/beyond-the-a...
examples/cms-prismic/pages/api/preview.js
@@ -11,10 +11,13 @@ function linkResolver(doc) { } export default async function preview(req, res) { - const ref = req.query.token + const { token: ref, documentId } = req.query // Check the token parameter against the Prismic SDK - const url = await PrismicClient.previewSession(ref, linkResolver, '/') + c...
true
Other
vercel
next.js
56d62a52fd706613de4800eeb7f6d4fff1b3af94.json
docs: include test env in default env vars (#13708) [Current Environment Variables doc](https://nextjs.org/docs/basic-features/environment-variables#default-environment-variables) mentions `development` and `production` env options but nothing about `test`. Test env is a 3rd valid option, and actually has some implica...
docs/basic-features/environment-variables.md
@@ -93,3 +93,13 @@ If you've configured [Development Environment Variables](https://vercel.com/docs ```bash vercel env pull .env.local ``` + +## Test Environment Variables + +Apart from `development` and `production` environments, there is a 3rd option available: `test`. In the same way you can set defaults for deve...
false
Other
vercel
next.js
e56a6add8de788baa6bee2865c469e6f7bdc1fb9.json
Add test for query param bug #15233 (#15238) Fixes https://github.com/vercel/next.js/issues/15233
test/integration/link-with-encoding/pages/index.js
@@ -30,6 +30,10 @@ const Home = () => ( > <a id="single-colon">Single: :</a> </Link> + <br /> + <Link href="/query?id=http://example.com/"> + <a id="url-param">Url query param</a> + </Link> </div> )
true
Other
vercel
next.js
e56a6add8de788baa6bee2865c469e6f7bdc1fb9.json
Add test for query param bug #15233 (#15238) Fixes https://github.com/vercel/next.js/issues/15233
test/integration/link-with-encoding/pages/query.js
@@ -0,0 +1,7 @@ +export function getServerSideProps({ query }) { + return { props: query } +} + +export default function Single(props) { + return <pre id="query-content">{JSON.stringify(props)}</pre> +}
true
Other
vercel
next.js
e56a6add8de788baa6bee2865c469e6f7bdc1fb9.json
Add test for query param bug #15233 (#15238) Fixes https://github.com/vercel/next.js/issues/15233
test/integration/link-with-encoding/test/index.test.js
@@ -295,5 +295,19 @@ describe('Link Component with Encoding', () => { await browser.close() } }) + + it('should have correct parsing of url query params', async () => { + const browser = await webdriver(appPort, '/') + try { + await browser.waitForElementByCss('#url-param').clic...
true
Other
vercel
next.js
bd9fc12f92915067e441b221a3652542687a7569.json
Fix ky-universal-polyfill in webpack 5 (#15227) Co-authored-by: kodiakhq[bot] <49736102+kodiakhq[bot]@users.noreply.github.com> Co-authored-by: Joe Haddad <joe.haddad@zeit.co>
package.json
@@ -122,6 +122,7 @@ "tree-kill": "1.2.1", "typescript": "3.8.3", "wait-port": "0.2.2", + "web-streams-polyfill": "2.1.1", "webpack-bundle-analyzer": "3.6.1", "worker-loader": "2.0.0" },
true
Other
vercel
next.js
bd9fc12f92915067e441b221a3652542687a7569.json
Fix ky-universal-polyfill in webpack 5 (#15227) Co-authored-by: kodiakhq[bot] <49736102+kodiakhq[bot]@users.noreply.github.com> Co-authored-by: Joe Haddad <joe.haddad@zeit.co>
yarn.lock
@@ -16016,6 +16016,11 @@ wcwidth@^1.0.0, wcwidth@^1.0.1: dependencies: defaults "^1.0.3" +web-streams-polyfill@2.1.1: + version "2.1.1" + resolved "https://registry.yarnpkg.com/web-streams-polyfill/-/web-streams-polyfill-2.1.1.tgz#2c82b6193849ccb9efaa267772c28260ef68d6d2" + integrity sha512-dlNpL2aab3g8CKf...
true
Other
vercel
next.js
3a9d18b549d064583bd715a3815691d7b33ceaa5.json
Add isReady field on router (#20628) Adds an `isReady` field on `next/router` specifying whether the router fields are updated client-side and ready for use. Should only be used inside of `useEffect` methods and not for conditionally rendering on the server. Closes: https://github.com/vercel/next.js/issues/8259 Close...
docs/api-reference/next/router.md
@@ -49,6 +49,7 @@ The following is the definition of the `router` object returned by both [`useRou - `locale`: `String` - The active locale (if enabled). - `locales`: `String[]` - All supported locales (if enabled). - `defaultLocale`: `String` - The current default locale (if enabled). +- `isReady`: `boolean` - Whet...
true
Other
vercel
next.js
3a9d18b549d064583bd715a3815691d7b33ceaa5.json
Add isReady field on router (#20628) Adds an `isReady` field on `next/router` specifying whether the router fields are updated client-side and ready for use. Should only be used inside of `useEffect` methods and not for conditionally rendering on the server. Closes: https://github.com/vercel/next.js/issues/8259 Close...
packages/next/client/router.ts
@@ -40,6 +40,7 @@ const urlPropertyFields = [ 'locale', 'locales', 'defaultLocale', + 'isReady', ] const routerEvents = [ 'routeChangeStart',
true
Other
vercel
next.js
3a9d18b549d064583bd715a3815691d7b33ceaa5.json
Add isReady field on router (#20628) Adds an `isReady` field on `next/router` specifying whether the router fields are updated client-side and ready for use. Should only be used inside of `useEffect` methods and not for conditionally rendering on the server. Closes: https://github.com/vercel/next.js/issues/8259 Close...
packages/next/next-server/lib/router/router.ts
@@ -25,6 +25,7 @@ import { loadGetInitialProps, NextPageContext, ST, + NEXT_DATA, } from '../utils' import { isDynamicRoute } from './utils/is-dynamic' import { parseRelativeUrl } from './utils/parse-relative-url' @@ -33,6 +34,13 @@ import resolveRewrites from './utils/resolve-rewrites' import { getRouteM...
true
Other
vercel
next.js
3a9d18b549d064583bd715a3815691d7b33ceaa5.json
Add isReady field on router (#20628) Adds an `isReady` field on `next/router` specifying whether the router fields are updated client-side and ready for use. Should only be used inside of `useEffect` methods and not for conditionally rendering on the server. Closes: https://github.com/vercel/next.js/issues/8259 Close...
packages/next/next-server/server/render.tsx
@@ -72,6 +72,7 @@ class ServerRouter implements NextRouter { events: any isFallback: boolean locale?: string + isReady: boolean locales?: string[] defaultLocale?: string domainLocales?: DomainLocales @@ -83,6 +84,7 @@ class ServerRouter implements NextRouter { query: ParsedUrlQuery, as: str...
true
Other
vercel
next.js
3a9d18b549d064583bd715a3815691d7b33ceaa5.json
Add isReady field on router (#20628) Adds an `isReady` field on `next/router` specifying whether the router fields are updated client-side and ready for use. Should only be used inside of `useEffect` methods and not for conditionally rendering on the server. Closes: https://github.com/vercel/next.js/issues/8259 Close...
test/integration/build-output/test/index.test.js
@@ -101,10 +101,10 @@ describe('Build Output', () => { expect(parseFloat(err404Size) - 3.7).toBeLessThanOrEqual(0) expect(err404Size.endsWith('kB')).toBe(true) - expect(parseFloat(err404FirstLoad)).toBeCloseTo(65.3, 1) + expect(parseFloat(err404FirstLoad)).toBeCloseTo(65.4, 1) expect(er...
true
Other
vercel
next.js
3a9d18b549d064583bd715a3815691d7b33ceaa5.json
Add isReady field on router (#20628) Adds an `isReady` field on `next/router` specifying whether the router fields are updated client-side and ready for use. Should only be used inside of `useEffect` methods and not for conditionally rendering on the server. Closes: https://github.com/vercel/next.js/issues/8259 Close...
test/integration/router-is-ready/pages/auto-export.js
@@ -0,0 +1,18 @@ +import { useRouter } from 'next/router' + +export default function Page(props) { + const router = useRouter() + + if (typeof window !== 'undefined') { + if (!window.isReadyValues) { + window.isReadyValues = [] + } + window.isReadyValues.push(router.isReady) + } + + return ( + <> +...
true
Other
vercel
next.js
3a9d18b549d064583bd715a3815691d7b33ceaa5.json
Add isReady field on router (#20628) Adds an `isReady` field on `next/router` specifying whether the router fields are updated client-side and ready for use. Should only be used inside of `useEffect` methods and not for conditionally rendering on the server. Closes: https://github.com/vercel/next.js/issues/8259 Close...
test/integration/router-is-ready/pages/gip.js
@@ -0,0 +1,26 @@ +import { useRouter } from 'next/router' + +export default function Page(props) { + const router = useRouter() + + if (typeof window !== 'undefined') { + if (!window.isReadyValues) { + window.isReadyValues = [] + } + window.isReadyValues.push(router.isReady) + } + + return ( + <> +...
true
Other
vercel
next.js
3a9d18b549d064583bd715a3815691d7b33ceaa5.json
Add isReady field on router (#20628) Adds an `isReady` field on `next/router` specifying whether the router fields are updated client-side and ready for use. Should only be used inside of `useEffect` methods and not for conditionally rendering on the server. Closes: https://github.com/vercel/next.js/issues/8259 Close...
test/integration/router-is-ready/pages/gsp.js
@@ -0,0 +1,28 @@ +import { useRouter } from 'next/router' + +export default function Page(props) { + const router = useRouter() + + if (typeof window !== 'undefined') { + if (!window.isReadyValues) { + window.isReadyValues = [] + } + window.isReadyValues.push(router.isReady) + } + + return ( + <> +...
true
Other
vercel
next.js
3a9d18b549d064583bd715a3815691d7b33ceaa5.json
Add isReady field on router (#20628) Adds an `isReady` field on `next/router` specifying whether the router fields are updated client-side and ready for use. Should only be used inside of `useEffect` methods and not for conditionally rendering on the server. Closes: https://github.com/vercel/next.js/issues/8259 Close...
test/integration/router-is-ready/pages/gssp.js
@@ -0,0 +1,28 @@ +import { useRouter } from 'next/router' + +export default function Page(props) { + const router = useRouter() + + if (typeof window !== 'undefined') { + if (!window.isReadyValues) { + window.isReadyValues = [] + } + window.isReadyValues.push(router.isReady) + } + + return ( + <> +...
true
Other
vercel
next.js
3a9d18b549d064583bd715a3815691d7b33ceaa5.json
Add isReady field on router (#20628) Adds an `isReady` field on `next/router` specifying whether the router fields are updated client-side and ready for use. Should only be used inside of `useEffect` methods and not for conditionally rendering on the server. Closes: https://github.com/vercel/next.js/issues/8259 Close...
test/integration/router-is-ready/pages/invalid.js
@@ -0,0 +1,15 @@ +import { useRouter } from 'next/router' + +export default function Page(props) { + // eslint-disable-next-line + const router = useRouter() + + // console.log(router.isReady) + + return ( + <> + <p id="invalid">invalid page</p> + <p id="props">{JSON.stringify(props)}</p> + </> + )...
true
Other
vercel
next.js
3a9d18b549d064583bd715a3815691d7b33ceaa5.json
Add isReady field on router (#20628) Adds an `isReady` field on `next/router` specifying whether the router fields are updated client-side and ready for use. Should only be used inside of `useEffect` methods and not for conditionally rendering on the server. Closes: https://github.com/vercel/next.js/issues/8259 Close...
test/integration/router-is-ready/test/index.test.js
@@ -0,0 +1,88 @@ +/* eslint-env jest */ + +import { join } from 'path' +import webdriver from 'next-webdriver' +import { + findPort, + launchApp, + killApp, + nextStart, + nextBuild, + File, +} from 'next-test-utils' + +jest.setTimeout(1000 * 60 * 1) + +let app +let appPort +const appDir = join(__dirname, '../') ...
true
Other
vercel
next.js
3a9d18b549d064583bd715a3815691d7b33ceaa5.json
Add isReady field on router (#20628) Adds an `isReady` field on `next/router` specifying whether the router fields are updated client-side and ready for use. Should only be used inside of `useEffect` methods and not for conditionally rendering on the server. Closes: https://github.com/vercel/next.js/issues/8259 Close...
test/integration/size-limit/test/index.test.js
@@ -81,6 +81,6 @@ describe('Production response size', () => { const delta = responseSizesBytes / 1024 // Expected difference: < 0.5 - expect(delta).toBeCloseTo(281.5, 0) + expect(delta).toBeCloseTo(282, 0) }) })
true
Other
vercel
next.js
380afbfba2a277ed19bc69a608cf5053c44cdcf7.json
Add docs on authentication patterns. (#16277) Building off [this Slack conversation](https://vercel.slack.com/archives/CGD3XGSD7/p1597329727013900), this PR adds a top-level section to the documentation on authentication patterns. Please provide any and all comments! A few open thoughts I have: - ~Should this includ...
docs/api-reference/next/router.md
@@ -100,7 +100,7 @@ export default function Page() { } ``` -Redirecting the user to `pages/login.js`, useful for pages behind authentication: +Redirecting the user to `pages/login.js`, useful for pages behind [authentication](/docs/authentication): ```jsx import { useEffect } from 'react'
true
Other
vercel
next.js
380afbfba2a277ed19bc69a608cf5053c44cdcf7.json
Add docs on authentication patterns. (#16277) Building off [this Slack conversation](https://vercel.slack.com/archives/CGD3XGSD7/p1597329727013900), this PR adds a top-level section to the documentation on authentication patterns. Please provide any and all comments! A few open thoughts I have: - ~Should this includ...
docs/authentication.md
@@ -0,0 +1,208 @@ +--- +description: Learn about authentication patterns in Next.js apps and explore a few examples. +--- + +# Authentication + +Authentication verifies who a user is, while authorization controls what a user can access. Next.js supports multiple authentication patterns, each designed for different use ...
true
Other
vercel
next.js
380afbfba2a277ed19bc69a608cf5053c44cdcf7.json
Add docs on authentication patterns. (#16277) Building off [this Slack conversation](https://vercel.slack.com/archives/CGD3XGSD7/p1597329727013900), this PR adds a top-level section to the documentation on authentication patterns. Please provide any and all comments! A few open thoughts I have: - ~Should this includ...
docs/manifest.json
@@ -93,6 +93,10 @@ "title": "Deployment", "path": "/docs/deployment.md" }, + { + "title": "Authentication", + "path": "/docs/authentication.md" + }, { "title": "Advanced Features", "routes": [
true
Other
vercel
next.js
74693810d05ef37d0923ee340e804cc255d37fd1.json
docs: update image docs for consistency (#20621)
docs/api-reference/next/image.md
@@ -13,17 +13,19 @@ description: Enable Image Optimization with the built-in Image component. <details> <summary><b>Version History</b></summary> - + | Version | Changes | | --------- | ------------------------ | | `v10.0.1` | `layout` prop added. | | `v10.0.0` | `next/image` introduc...
false
Other
vercel
next.js
ec430ea77db6e934cffa6cc1756e584c36d3a1fc.json
Fix memory leak in useIntersection (#20407) This pull request adds an `elements.delete` operation to the `useIntersection`'s cleanup function: `unobserve`. Without this delete operation, next.js holds onto an unreachable reference of every observed element indefinitely (automatically every Link and Image is observed,...
packages/next/client/use-intersection.tsx
@@ -55,6 +55,7 @@ function observe( observer.observe(element) return function unobserve() { + elements.delete(element) observer.unobserve(element) // Destroy observer when there's nothing left to watch:
false
Other
vercel
next.js
d1c565901e342cfb6354cefe67001292ac6b6182.json
feat(next/image): reduce byte waste for 3x screens (#20610) https://blog.twitter.com/engineering/en_us/topics/infrastructure/2019/capping-image-fidelity-on-ultra-high-resolution-devices.html > This means that most OLED screens that say they are 3x resolution, are actually 3x in the green color, but only 1.5x in the r...
packages/next/client/image.tsx
@@ -86,7 +86,15 @@ function getWidths( const widths = [ ...new Set( - [width, width * 2, width * 3].map( + // > This means that most OLED screens that say they are 3x resolution, + // > are actually 3x in the green color, but only 1.5x in the red and + // > blue colors. Showing a 3x resolu...
true
Other
vercel
next.js
d1c565901e342cfb6354cefe67001292ac6b6182.json
feat(next/image): reduce byte waste for 3x screens (#20610) https://blog.twitter.com/engineering/en_us/topics/infrastructure/2019/capping-image-fidelity-on-ultra-high-resolution-devices.html > This means that most OLED screens that say they are 3x resolution, are actually 3x in the green color, but only 1.5x in the r...
test/integration/image-component/base-path/test/index.test.js
@@ -101,7 +101,7 @@ function runTests(mode) { expect( await hasImageMatchingUrl( browser, - `http://localhost:${appPort}/docs/_next/image?url=%2Fdocs%2Ftest.jpg&w=1200&q=75` + `http://localhost:${appPort}/docs/_next/image?url=%2Fdocs%2Ftest.jpg&w=828&q=75` ) ...
true
Other
vercel
next.js
d1c565901e342cfb6354cefe67001292ac6b6182.json
feat(next/image): reduce byte waste for 3x screens (#20610) https://blog.twitter.com/engineering/en_us/topics/infrastructure/2019/capping-image-fidelity-on-ultra-high-resolution-devices.html > This means that most OLED screens that say they are 3x resolution, are actually 3x in the green color, but only 1.5x in the r...
test/integration/image-component/basic/test/index.test.js
@@ -61,20 +61,20 @@ function runTests() { }) it('should use imageSizes when width matches, not deviceSizes from next.config.js', async () => { expect(await browser.elementById('icon-image-16').getAttribute('src')).toBe( - 'https://example.com/myaccount/icon.png?auto=format&fit=max&w=48' + 'https://...
true
Other
vercel
next.js
d1c565901e342cfb6354cefe67001292ac6b6182.json
feat(next/image): reduce byte waste for 3x screens (#20610) https://blog.twitter.com/engineering/en_us/topics/infrastructure/2019/capping-image-fidelity-on-ultra-high-resolution-devices.html > This means that most OLED screens that say they are 3x resolution, are actually 3x in the green color, but only 1.5x in the r...
test/integration/image-component/default/test/index.test.js
@@ -101,7 +101,7 @@ function runTests(mode) { expect( await hasImageMatchingUrl( browser, - `http://localhost:${appPort}/_next/image?url=%2Ftest.jpg&w=1200&q=75` + `http://localhost:${appPort}/_next/image?url=%2Ftest.jpg&w=828&q=75` ) ).toBe(true) } fina...
true
Other
vercel
next.js
8bab640ef63fcdf690f8431ea20351ebc5cb4864.json
fix(next/link): reset scroll before lifecycles (#20595) This moves the scroll reset behavior to happen synchronously with the DOM commit, instead of a few ticks after the render completes. This is necessary for components that read scroll state on mount. --- Fixes #6462
packages/next/client/index.tsx
@@ -5,18 +5,22 @@ import ReactDOM from 'react-dom' import { HeadManagerContext } from '../next-server/lib/head-manager-context' import mitt from '../next-server/lib/mitt' import { RouterContext } from '../next-server/lib/router-context' -import Router from '../next-server/lib/router/router' -import { +import Router,...
true
Other
vercel
next.js
8bab640ef63fcdf690f8431ea20351ebc5cb4864.json
fix(next/link): reset scroll before lifecycles (#20595) This moves the scroll reset behavior to happen synchronously with the DOM commit, instead of a few ticks after the render completes. This is necessary for components that read scroll state on mount. --- Fixes #6462
packages/next/client/link.tsx
@@ -98,15 +98,17 @@ function linkClicked( } // replace state instead of push if prop is present - router[replace ? 'replace' : 'push'](href, as, { shallow, locale }).then( - (success: boolean) => { - if (!success) return - if (scroll) { - window.scrollTo(0, 0) - document.body.focus()...
true
Other
vercel
next.js
8bab640ef63fcdf690f8431ea20351ebc5cb4864.json
fix(next/link): reset scroll before lifecycles (#20595) This moves the scroll reset behavior to happen synchronously with the DOM commit, instead of a few ticks after the render completes. This is necessary for components that read scroll state on mount. --- Fixes #6462
packages/next/next-server/lib/router/router.ts
@@ -39,6 +39,7 @@ interface RouteProperties { interface TransitionOptions { shallow?: boolean locale?: string | false + scroll?: boolean } interface NextHistoryState { @@ -314,7 +315,11 @@ export type AppProps = Pick<CompletePrivateRouteInfo, 'Component' | 'err'> & { } & Record<string, any> export type Ap...
true
Other
vercel
next.js
8bab640ef63fcdf690f8431ea20351ebc5cb4864.json
fix(next/link): reset scroll before lifecycles (#20595) This moves the scroll reset behavior to happen synchronously with the DOM commit, instead of a few ticks after the render completes. This is necessary for components that read scroll state on mount. --- Fixes #6462
test/integration/client-navigation/pages/nav/long-page-to-snap-scroll.js
@@ -0,0 +1,26 @@ +import Link from 'next/link' +import React from 'react' + +const LongPageToSnapScroll = () => { + return ( + <div id="long-page-to-snap-scroll"> + <Link href="#item-400"> + <a id="scroll-to-item-400">Go to item 400</a> + </Link> + + {Array.from({ length: 500 }, (x, i) => i + ...
true
Other
vercel
next.js
8bab640ef63fcdf690f8431ea20351ebc5cb4864.json
fix(next/link): reset scroll before lifecycles (#20595) This moves the scroll reset behavior to happen synchronously with the DOM commit, instead of a few ticks after the render completes. This is necessary for components that read scroll state on mount. --- Fixes #6462
test/integration/client-navigation/pages/snap-scroll-position.js
@@ -0,0 +1,28 @@ +import React from 'react' + +export default class SnapScrollPosition extends React.Component { + constructor(props) { + super(props) + this.state = { positionY: -1 } + } + + componentDidMount() { + this.setState({ positionY: window.scrollY }) + } + + render() { + return ( + <main...
true
Other
vercel
next.js
8bab640ef63fcdf690f8431ea20351ebc5cb4864.json
fix(next/link): reset scroll before lifecycles (#20595) This moves the scroll reset behavior to happen synchronously with the DOM commit, instead of a few ticks after the render completes. This is necessary for components that read scroll state on mount. --- Fixes #6462
test/integration/client-navigation/test/index.test.js
@@ -444,6 +444,42 @@ describe('Client Navigation', () => { }) }) + describe('resets scroll at the correct time', () => { + it('should reset scroll before the new page runs its lifecycles', async () => { + let browser + try { + browser = await webdriver( + context.appPort, + ...
true
Other
vercel
next.js
d33d1dd00a6a7c65ca7158b83c787902afcac237.json
Ignore domains option when loader is set (#18447) ``` images: { domains: ['example.com'], path: 'https://example.com/myaccount/', }, ``` Those `domains` and `path` look a lot alike for me and so, I was confused. I found out that the domains are ignored if the Loader is set, which makes sense.
docs/basic-features/image-optimization.md
@@ -59,7 +59,7 @@ In addition to [using properties](/docs/api-reference/next/image.md) available t ### Domains To enable Image Optimization for images hosted on an external website, use an absolute url for the Image `src` and specify which -`domains` are allowed to be optimized. This is needed to ensure that extern...
false
Other
vercel
next.js
52270af307a8df392e587516560b80e2d8b8284e.json
Remove unnecessary unfetch polyfill for dev (#20589) Fetch is always polyfilled in legacy browsers by `@next/polyfill-nomodule`, so we do not need to import unfetch for IE11 support. Fixes #20588
packages/next/client/dev/amp-dev.js
@@ -1,5 +1,4 @@ /* globals __webpack_hash__ */ -import fetch from 'next/dist/build/polyfills/unfetch' import EventSourcePolyfill from './event-source-polyfill' import { getEventSourceWrapper } from './error-overlay/eventsource' import { setupPing } from './on-demand-entries-utils'
true
Other
vercel
next.js
52270af307a8df392e587516560b80e2d8b8284e.json
Remove unnecessary unfetch polyfill for dev (#20589) Fetch is always polyfilled in legacy browsers by `@next/polyfill-nomodule`, so we do not need to import unfetch for IE11 support. Fixes #20588
packages/next/client/dev/event-source-polyfill.js
@@ -2,8 +2,6 @@ // Improved version of https://github.com/Yaffle/EventSource/ // Available under MIT License (MIT) // Only tries to support IE11 and nothing below -import fetch from 'next/dist/build/polyfills/unfetch' - var document = window.document var Response = window.Response var TextDecoder = window.TextDec...
true
Other
vercel
next.js
52270af307a8df392e587516560b80e2d8b8284e.json
Remove unnecessary unfetch polyfill for dev (#20589) Fetch is always polyfilled in legacy browsers by `@next/polyfill-nomodule`, so we do not need to import unfetch for IE11 support. Fixes #20588
packages/next/client/dev/on-demand-entries-utils.js
@@ -1,6 +1,4 @@ /* global location */ - -import fetch from 'next/dist/build/polyfills/unfetch' import { getEventSourceWrapper } from './error-overlay/eventsource' let evtSource
true
Other
vercel
next.js
52270af307a8df392e587516560b80e2d8b8284e.json
Remove unnecessary unfetch polyfill for dev (#20589) Fetch is always polyfilled in legacy browsers by `@next/polyfill-nomodule`, so we do not need to import unfetch for IE11 support. Fixes #20588
packages/next/package.json
@@ -218,7 +218,6 @@ "text-table": "0.2.0", "thread-loader": "2.1.3", "typescript": "3.8.3", - "unfetch": "4.1.0", "unistore": "3.4.1", "web-vitals": "0.2.4" },
true
Other
vercel
next.js
52270af307a8df392e587516560b80e2d8b8284e.json
Remove unnecessary unfetch polyfill for dev (#20589) Fetch is always polyfilled in legacy browsers by `@next/polyfill-nomodule`, so we do not need to import unfetch for IE11 support. Fixes #20588
packages/next/pages/_document.tsx
@@ -731,6 +731,7 @@ export class NextScript extends Component<OriginProps> { const ampDevFiles = [ ...buildManifest.devFiles, + ...buildManifest.polyfillFiles, ...buildManifest.ampDevFiles, ]
true
Other
vercel
next.js
52270af307a8df392e587516560b80e2d8b8284e.json
Remove unnecessary unfetch polyfill for dev (#20589) Fetch is always polyfilled in legacy browsers by `@next/polyfill-nomodule`, so we do not need to import unfetch for IE11 support. Fixes #20588
packages/next/taskfile.js
@@ -11,14 +11,8 @@ export async function next__polyfill_nomodule(task, opts) { .target('dist/build/polyfills') } -export async function unfetch(task, opts) { - await task - .source(opts.src || relative(__dirname, require.resolve('unfetch'))) - .target('dist/build/polyfills') -} - export async function b...
true
Other
vercel
next.js
52270af307a8df392e587516560b80e2d8b8284e.json
Remove unnecessary unfetch polyfill for dev (#20589) Fetch is always polyfilled in legacy browsers by `@next/polyfill-nomodule`, so we do not need to import unfetch for IE11 support. Fixes #20588
packages/next/types/misc.d.ts
@@ -8,7 +8,6 @@ declare module 'cssnano-simple' { export = cssnanoSimple } declare module 'styled-jsx/server' -declare module 'unfetch' declare module 'webpack/lib/GraphHelpers' declare module 'webpack/lib/DynamicEntryPlugin' declare module 'webpack/lib/Entrypoint'
true
Other
vercel
next.js
52270af307a8df392e587516560b80e2d8b8284e.json
Remove unnecessary unfetch polyfill for dev (#20589) Fetch is always polyfilled in legacy browsers by `@next/polyfill-nomodule`, so we do not need to import unfetch for IE11 support. Fixes #20588
test/integration/amphtml/test/index.test.js
@@ -298,7 +298,20 @@ describe('AMP Usage', () => { const html = await renderViaHTTP(dynamicAppPort, '/only-amp') const $ = cheerio.load(html) expect($('html').attr('data-ampdevmode')).toBe('') - expect($('script[data-ampdevmode]').length).toBe(4) + expect( + [].slice + .ap...
true
Other
vercel
next.js
52270af307a8df392e587516560b80e2d8b8284e.json
Remove unnecessary unfetch polyfill for dev (#20589) Fetch is always polyfilled in legacy browsers by `@next/polyfill-nomodule`, so we do not need to import unfetch for IE11 support. Fixes #20588
yarn.lock
@@ -15475,7 +15475,7 @@ umask@^1.1.0: version "1.1.0" resolved "https://registry.yarnpkg.com/umask/-/umask-1.1.0.tgz#f29cebf01df517912bb58ff9c4e50fde8e33320d" -unfetch@4.1.0, unfetch@^4.0.0: +unfetch@^4.0.0: version "4.1.0" resolved "https://registry.yarnpkg.com/unfetch/-/unfetch-4.1.0.tgz#6ec2dd0de887e58...
true
Other
vercel
next.js
a9c7c9a5f57bef1cb914eeed796acc65b9ca2559.json
Update sharp optional dependency to support NPM 7 (#20432) Sharp 0.26.3 updates prebuild-install to ^6.0.0 which fixes an incompatibility with NPM 7. See https://github.com/lovell/sharp/pull/2419 and https://github.com/prebuild/prebuild-install/pull/128
packages/next/package.json
@@ -112,7 +112,7 @@ "react-dom": "^16.6.0 || ^17" }, "optionalDependencies": { - "sharp": "0.26.2" + "sharp": "0.26.3" }, "devDependencies": { "@babel/code-frame": "7.10.4",
true
Other
vercel
next.js
a9c7c9a5f57bef1cb914eeed796acc65b9ca2559.json
Update sharp optional dependency to support NPM 7 (#20432) Sharp 0.26.3 updates prebuild-install to ^6.0.0 which fixes an incompatibility with NPM 7. See https://github.com/lovell/sharp/pull/2419 and https://github.com/prebuild/prebuild-install/pull/128
yarn.lock
@@ -3636,6 +3636,11 @@ array-flatten@1.1.1: version "1.1.1" resolved "https://registry.yarnpkg.com/array-flatten/-/array-flatten-1.1.1.tgz#9a5f699051b1e7073328f2a008968b64ea2955d2" +array-flatten@^3.0.0: + version "3.0.0" + resolved "https://registry.yarnpkg.com/array-flatten/-/array-flatten-3.0.0.tgz#6428ca2...
true
Other
vercel
next.js
b540054388b7121ec974e1d7bec19a181063799d.json
Update authentication examples (#19330) * Updated example readme * Updated with-passport example * Updated profile page for with-passport * Updated with-passport-and-next-connect * Updated with-magic * Updated with-magic readme * Updated with-iron-session * Updated next version in with-iron-sessio...
examples/api-routes-apollo-server-and-client-auth/README.md
@@ -4,6 +4,12 @@ In this simple example, we integrate Apollo seamlessly with [Next.js data fetching methods](https://nextjs.org/docs/basic-features/data-fetching) to fetch queries in the server and hydrate them in the browser. +## Deploy your own + +Deploy the example using [Vercel](https://vercel.com): + +[![Depl...
true
Other
vercel
next.js
b540054388b7121ec974e1d7bec19a181063799d.json
Update authentication examples (#19330) * Updated example readme * Updated with-passport example * Updated profile page for with-passport * Updated with-passport-and-next-connect * Updated with-magic * Updated with-magic readme * Updated with-iron-session * Updated next version in with-iron-sessio...
examples/api-routes-apollo-server-and-client-auth/lib/auth.js
@@ -21,7 +21,9 @@ export async function getLoginSession(req) { const expiresAt = session.createdAt + session.maxAge * 1000 // Validate the expiration date of the session - if (Date.now() < expiresAt) { - return session + if (Date.now() > expiresAt) { + throw new Error('Session expired') } + + return...
true
Other
vercel
next.js
b540054388b7121ec974e1d7bec19a181063799d.json
Update authentication examples (#19330) * Updated example readme * Updated with-passport example * Updated profile page for with-passport * Updated with-passport-and-next-connect * Updated with-magic * Updated with-magic readme * Updated with-iron-session * Updated next version in with-iron-sessio...
examples/with-iron-session/package.json
@@ -8,7 +8,7 @@ "start": "next start" }, "dependencies": { - "next": "^9.4.4", + "next": "latest", "next-iron-session": "4.1.7", "prop-types": "15.7.2", "react": "16.13.1",
true
Other
vercel
next.js
b540054388b7121ec974e1d7bec19a181063799d.json
Update authentication examples (#19330) * Updated example readme * Updated with-passport example * Updated profile page for with-passport * Updated with-passport-and-next-connect * Updated with-magic * Updated with-magic readme * Updated with-iron-session * Updated next version in with-iron-sessio...
examples/with-iron-session/pages/profile-sg.js
@@ -25,7 +25,7 @@ const SgProfile = () => { <a href={githubUrl(user.login)}>{githubUrl(user.login)}</a>, reduced to `login` and `avatar_url`. </p> - <pre>{JSON.stringify(user, undefined, 2)}</pre> + <pre>{JSON.stringify(user, null, 2)}</pre> </Layout> ) }
true
Other
vercel
next.js
b540054388b7121ec974e1d7bec19a181063799d.json
Update authentication examples (#19330) * Updated example readme * Updated with-passport example * Updated profile page for with-passport * Updated with-passport-and-next-connect * Updated with-magic * Updated with-magic readme * Updated with-iron-session * Updated next version in with-iron-sessio...
examples/with-iron-session/pages/profile-ssr.js
@@ -24,7 +24,7 @@ const SsrProfile = ({ user }) => { <a href={githubUrl(user.login)}>{githubUrl(user.login)}</a>, reduced to `login` and `avatar_url`. </p> - <pre>{JSON.stringify(user, undefined, 2)}</pre> + <pre>{JSON.stringify(user, null, 2)}</pre> </> ...
true
Other
vercel
next.js
b540054388b7121ec974e1d7bec19a181063799d.json
Update authentication examples (#19330) * Updated example readme * Updated with-passport example * Updated profile page for with-passport * Updated with-passport-and-next-connect * Updated with-magic * Updated with-magic readme * Updated with-iron-session * Updated next version in with-iron-sessio...
examples/with-magic/.env.local.example
@@ -1,2 +1,3 @@ NEXT_PUBLIC_MAGIC_PUBLISHABLE_KEY= MAGIC_SECRET_KEY= +TOKEN_SECRET="this-is-a-secret-value-with-at-least-32-characters"
true
Other
vercel
next.js
b540054388b7121ec974e1d7bec19a181063799d.json
Update authentication examples (#19330) * Updated example readme * Updated with-passport example * Updated profile page for with-passport * Updated with-passport-and-next-connect * Updated with-magic * Updated with-magic readme * Updated with-iron-session * Updated next version in with-iron-sessio...
examples/with-magic/README.md
@@ -1,6 +1,6 @@ # Magic Example -This example show how to use [Magic](https://magic.link) with Next.js. The example features cookie-based, passwordless authentication with email-based magic links. +This example shows how to use [Magic](https://magic.link) with Next.js. The example features cookie-based, passwordless...
true
Other
vercel
next.js
b540054388b7121ec974e1d7bec19a181063799d.json
Update authentication examples (#19330) * Updated example readme * Updated with-passport example * Updated profile page for with-passport * Updated with-passport-and-next-connect * Updated with-magic * Updated with-magic readme * Updated with-iron-session * Updated next version in with-iron-sessio...
examples/with-magic/lib/auth-cookies.js
@@ -1,7 +1,8 @@ import { serialize, parse } from 'cookie' const TOKEN_NAME = 'token' -const MAX_AGE = 60 * 60 * 8 // 8 hours + +export const MAX_AGE = 60 * 60 * 8 // 8 hours export function setTokenCookie(res, token) { const cookie = serialize(TOKEN_NAME, token, { @@ -12,6 +13,7 @@ export function setTokenCoo...
true
Other
vercel
next.js
b540054388b7121ec974e1d7bec19a181063799d.json
Update authentication examples (#19330) * Updated example readme * Updated with-passport example * Updated profile page for with-passport * Updated with-passport-and-next-connect * Updated with-magic * Updated with-magic readme * Updated with-iron-session * Updated next version in with-iron-sessio...
examples/with-magic/lib/auth.js
@@ -0,0 +1,29 @@ +import Iron from '@hapi/iron' +import { MAX_AGE, setTokenCookie, getTokenCookie } from './auth-cookies' + +const TOKEN_SECRET = process.env.TOKEN_SECRET + +export async function setLoginSession(res, session) { + const createdAt = Date.now() + // Create a session object with a max age that we can val...
true
Other
vercel
next.js
b540054388b7121ec974e1d7bec19a181063799d.json
Update authentication examples (#19330) * Updated example readme * Updated with-passport example * Updated profile page for with-passport * Updated with-passport-and-next-connect * Updated with-magic * Updated with-magic readme * Updated with-iron-session * Updated next version in with-iron-sessio...
examples/with-magic/lib/iron.js
@@ -1,14 +0,0 @@ -import Iron from '@hapi/iron' -import { getTokenCookie } from './auth-cookies' - -// Use an environment variable here instead of a hardcoded value for production -const TOKEN_SECRET = 'this-is-a-secret-value-with-at-least-32-characters' - -export function encryptSession(session) { - return Iron.seal(...
true
Other
vercel
next.js
b540054388b7121ec974e1d7bec19a181063799d.json
Update authentication examples (#19330) * Updated example readme * Updated with-passport example * Updated profile page for with-passport * Updated with-passport-and-next-connect * Updated with-magic * Updated with-magic readme * Updated with-iron-session * Updated next version in with-iron-sessio...
examples/with-magic/pages/api/login.js
@@ -1,15 +1,14 @@ import { magic } from '../../lib/magic' -import { encryptSession } from '../../lib/iron' -import { setTokenCookie } from '../../lib/auth-cookies' +import { setLoginSession } from '../../lib/auth' export default async function login(req, res) { try { const didToken = req.headers.authorizati...
true
Other
vercel
next.js
b540054388b7121ec974e1d7bec19a181063799d.json
Update authentication examples (#19330) * Updated example readme * Updated with-passport example * Updated profile page for with-passport * Updated with-passport-and-next-connect * Updated with-magic * Updated with-magic readme * Updated with-iron-session * Updated next version in with-iron-sessio...
examples/with-magic/pages/api/logout.js
@@ -1,11 +1,19 @@ import { magic } from '../../lib/magic' import { removeTokenCookie } from '../../lib/auth-cookies' -import { getSession } from '../../lib/iron' +import { getLoginSession } from '../../lib/auth' export default async function logout(req, res) { - const session = await getSession(req) - await magi...
true
Other
vercel
next.js
b540054388b7121ec974e1d7bec19a181063799d.json
Update authentication examples (#19330) * Updated example readme * Updated with-passport example * Updated profile page for with-passport * Updated with-passport-and-next-connect * Updated with-magic * Updated with-magic readme * Updated with-iron-session * Updated next version in with-iron-sessio...
examples/with-magic/pages/api/user.js
@@ -1,7 +1,7 @@ -import { getSession } from '../../lib/iron' +import { getLoginSession } from '../../lib/auth' export default async function user(req, res) { - const session = await getSession(req) + const session = await getLoginSession(req) // After getting the session you may want to fetch for the user inste...
true
Other
vercel
next.js
b540054388b7121ec974e1d7bec19a181063799d.json
Update authentication examples (#19330) * Updated example readme * Updated with-passport example * Updated profile page for with-passport * Updated with-passport-and-next-connect * Updated with-magic * Updated with-magic readme * Updated with-iron-session * Updated next version in with-iron-sessio...
examples/with-magic/pages/index.js
@@ -45,6 +45,10 @@ const Home = () => { li { margin-bottom: 0.5rem; } + pre { + white-space: pre-wrap; + word-wrap: break-word; + } `}</style> </Layout> )
true
Other
vercel
next.js
b540054388b7121ec974e1d7bec19a181063799d.json
Update authentication examples (#19330) * Updated example readme * Updated with-passport example * Updated profile page for with-passport * Updated with-passport-and-next-connect * Updated with-magic * Updated with-magic readme * Updated with-iron-session * Updated next version in with-iron-sessio...
examples/with-magic/pages/profile.js
@@ -7,12 +7,20 @@ const Profile = () => { return ( <Layout> <h1>Profile</h1> + {user && ( <> <p>Your session:</p> <pre>{JSON.stringify(user, null, 2)}</pre> </> )} + + <style jsx>{` + pre { + white-space: pre-wrap; + word...
true
Other
vercel
next.js
b540054388b7121ec974e1d7bec19a181063799d.json
Update authentication examples (#19330) * Updated example readme * Updated with-passport example * Updated profile page for with-passport * Updated with-passport-and-next-connect * Updated with-magic * Updated with-magic readme * Updated with-iron-session * Updated next version in with-iron-sessio...
examples/with-passport-and-next-connect/.env
@@ -0,0 +1,3 @@ +# Secrets like the one below should go into `.env.local` instead to avoid pushing +# them to a repository, this is an exception for the sake of the example +TOKEN_SECRET="this-is-a-secret-value-with-at-least-32-characters" \ No newline at end of file
true
Other
vercel
next.js
b540054388b7121ec974e1d7bec19a181063799d.json
Update authentication examples (#19330) * Updated example readme * Updated with-passport example * Updated profile page for with-passport * Updated with-passport-and-next-connect * Updated with-magic * Updated with-magic readme * Updated with-iron-session * Updated next version in with-iron-sessio...
examples/with-passport-and-next-connect/README.md
@@ -6,8 +6,6 @@ The example shows how to do a sign up, login, logout, and account deactivation. For demo purpose, the users database is stored in the cookie session. You need to replace it with an actual database to store users in [db.js](lib/db.js). -In production, you must use a password hashing library, such as...
true
Other
vercel
next.js
b540054388b7121ec974e1d7bec19a181063799d.json
Update authentication examples (#19330) * Updated example readme * Updated with-passport example * Updated profile page for with-passport * Updated with-passport-and-next-connect * Updated with-magic * Updated with-magic readme * Updated with-iron-session * Updated next version in with-iron-sessio...
examples/with-passport-and-next-connect/lib/auth.js
@@ -0,0 +1,21 @@ +import Iron from '@hapi/iron' + +export async function createLoginSession(session, secret) { + const createdAt = Date.now() + const obj = { ...session, createdAt } + const token = await Iron.seal(obj, secret, Iron.defaults) + + return token +} + +export async function getLoginSession(token, secret...
true
Other
vercel
next.js
b540054388b7121ec974e1d7bec19a181063799d.json
Update authentication examples (#19330) * Updated example readme * Updated with-passport example * Updated profile page for with-passport * Updated with-passport-and-next-connect * Updated with-magic * Updated with-magic readme * Updated with-iron-session * Updated next version in with-iron-sessio...
examples/with-passport-and-next-connect/lib/db.js
@@ -1,9 +1,27 @@ +import crypto from 'crypto' +import { v4 as uuidv4 } from 'uuid' + export function getAllUsers(req) { // For demo purpose only. You are not likely to have to return all users. return req.session.users } -export function createUser(req, user) { +export function createUser(req, { username, pas...
true
Other
vercel
next.js
b540054388b7121ec974e1d7bec19a181063799d.json
Update authentication examples (#19330) * Updated example readme * Updated with-passport example * Updated profile page for with-passport * Updated with-passport-and-next-connect * Updated with-magic * Updated with-magic readme * Updated with-iron-session * Updated next version in with-iron-sessio...
examples/with-passport-and-next-connect/lib/passport.js
@@ -1,6 +1,6 @@ import passport from 'passport' import LocalStrategy from 'passport-local' -import { findUserByUsername } from './db' +import { findUserByUsername, validatePassword } from './db' passport.serializeUser(function (user, done) { // serialize the username into session @@ -21,7 +21,7 @@ passport.use(...
true
Other
vercel
next.js
b540054388b7121ec974e1d7bec19a181063799d.json
Update authentication examples (#19330) * Updated example readme * Updated with-passport example * Updated profile page for with-passport * Updated with-passport-and-next-connect * Updated with-magic * Updated with-magic readme * Updated with-iron-session * Updated next version in with-iron-sessio...
examples/with-passport-and-next-connect/lib/session.js
@@ -1,29 +1,43 @@ import { parse, serialize } from 'cookie' -import Iron from '@hapi/iron' +import { createLoginSession, getLoginSession } from './auth' + +function parseCookies(req) { + // For API Routes we don't need to parse the cookies. + if (req.cookies) return req.cookies + + // For pages we do need to parse ...
true
Other
vercel
next.js
b540054388b7121ec974e1d7bec19a181063799d.json
Update authentication examples (#19330) * Updated example readme * Updated with-passport example * Updated profile page for with-passport * Updated with-passport-and-next-connect * Updated with-magic * Updated with-magic readme * Updated with-iron-session * Updated next version in with-iron-sessio...
examples/with-passport-and-next-connect/middleware/auth.js
@@ -6,7 +6,7 @@ const auth = nextConnect() .use( session({ name: 'sess', - secret: 'some_not_random_password_that_is_at_least_32_characters', // This should be kept securely, preferably in env vars + secret: process.env.TOKEN_SECRET, cookie: { maxAge: 60 * 60 * 8, // 8 hours, ...
true
Other
vercel
next.js
b540054388b7121ec974e1d7bec19a181063799d.json
Update authentication examples (#19330) * Updated example readme * Updated with-passport example * Updated profile page for with-passport * Updated with-passport-and-next-connect * Updated with-magic * Updated with-magic readme * Updated with-iron-session * Updated next version in with-iron-sessio...
examples/with-passport-and-next-connect/package.json
@@ -14,7 +14,8 @@ "passport-local": "^1.0.0", "react": "^16.13.1", "react-dom": "^16.13.1", - "swr": "^0.1.18" + "swr": "^0.1.18", + "uuidv4": "6.2.5" }, "license": "MIT" }
true
Other
vercel
next.js
b540054388b7121ec974e1d7bec19a181063799d.json
Update authentication examples (#19330) * Updated example readme * Updated with-passport example * Updated profile page for with-passport * Updated with-passport-and-next-connect * Updated with-magic * Updated with-magic readme * Updated with-iron-session * Updated next version in with-iron-sessio...
examples/with-passport-and-next-connect/pages/index.js
@@ -9,8 +9,17 @@ function UserList() { {!!users?.length && ( <ul> {users.map((user) => ( - <li key={user.username}>{JSON.stringify(user)}</li> + <li key={user.username}> + <pre>{JSON.stringify(user, null, 2)}</pre> + </li> ))} + + ...
true
Other
vercel
next.js
b540054388b7121ec974e1d7bec19a181063799d.json
Update authentication examples (#19330) * Updated example readme * Updated with-passport example * Updated profile page for with-passport * Updated with-passport-and-next-connect * Updated with-magic * Updated with-magic readme * Updated with-iron-session * Updated next version in with-iron-sessio...
examples/with-passport-and-next-connect/pages/profile.js
@@ -78,12 +78,21 @@ export default function ProfilePage() { return ( <> <h1>Profile</h1> + {user && ( <> - <p>Your profile: {JSON.stringify(user)}</p> + <p>Your session:</p> + <pre>{JSON.stringify(user, null, 2)}</pre> <ProfileEdit /> </> ...
true
Other
vercel
next.js
b540054388b7121ec974e1d7bec19a181063799d.json
Update authentication examples (#19330) * Updated example readme * Updated with-passport example * Updated profile page for with-passport * Updated with-passport-and-next-connect * Updated with-magic * Updated with-magic readme * Updated with-iron-session * Updated next version in with-iron-sessio...
examples/with-passport/.env
@@ -0,0 +1,3 @@ +# Secrets like the one below should go into `.env.local` instead to avoid pushing +# them to a repository, this is an exception for the sake of the example +TOKEN_SECRET="this-is-a-secret-value-with-at-least-32-characters" \ No newline at end of file
true
Other
vercel
next.js
b540054388b7121ec974e1d7bec19a181063799d.json
Update authentication examples (#19330) * Updated example readme * Updated with-passport example * Updated profile page for with-passport * Updated with-passport-and-next-connect * Updated with-magic * Updated with-magic readme * Updated with-iron-session * Updated next version in with-iron-sessio...
examples/with-passport/lib/auth-cookies.js
@@ -1,7 +1,8 @@ import { serialize, parse } from 'cookie' const TOKEN_NAME = 'token' -const MAX_AGE = 60 * 60 * 8 // 8 hours + +export const MAX_AGE = 60 * 60 * 8 // 8 hours export function setTokenCookie(res, token) { const cookie = serialize(TOKEN_NAME, token, {
true
Other
vercel
next.js
b540054388b7121ec974e1d7bec19a181063799d.json
Update authentication examples (#19330) * Updated example readme * Updated with-passport example * Updated profile page for with-passport * Updated with-passport-and-next-connect * Updated with-magic * Updated with-magic readme * Updated with-iron-session * Updated next version in with-iron-sessio...
examples/with-passport/lib/auth.js
@@ -0,0 +1,29 @@ +import Iron from '@hapi/iron' +import { MAX_AGE, setTokenCookie, getTokenCookie } from './auth-cookies' + +const TOKEN_SECRET = process.env.TOKEN_SECRET + +export async function setLoginSession(res, session) { + const createdAt = Date.now() + // Create a session object with a max age that we can val...
true
Other
vercel
next.js
b540054388b7121ec974e1d7bec19a181063799d.json
Update authentication examples (#19330) * Updated example readme * Updated with-passport example * Updated profile page for with-passport * Updated with-passport-and-next-connect * Updated with-magic * Updated with-magic readme * Updated with-iron-session * Updated next version in with-iron-sessio...
examples/with-passport/lib/iron.js
@@ -1,14 +0,0 @@ -import Iron from '@hapi/iron' -import { getTokenCookie } from './auth-cookies' - -// Use an environment variable here instead of a hardcoded value for production -const TOKEN_SECRET = 'this-is-a-secret-value-with-at-least-32-characters' - -export function encryptSession(session) { - return Iron.seal(...
true
Other
vercel
next.js
b540054388b7121ec974e1d7bec19a181063799d.json
Update authentication examples (#19330) * Updated example readme * Updated with-passport example * Updated profile page for with-passport * Updated with-passport-and-next-connect * Updated with-magic * Updated with-magic readme * Updated with-iron-session * Updated next version in with-iron-sessio...
examples/with-passport/lib/password-local.js
@@ -1,14 +1,18 @@ import Local from 'passport-local' -import { findUser } from './user' +import { findUser, validatePassword } from './user' export const localStrategy = new Local.Strategy(function ( username, password, done ) { - findUser({ username, password }) + findUser({ username }) .then((use...
true
Other
vercel
next.js
b540054388b7121ec974e1d7bec19a181063799d.json
Update authentication examples (#19330) * Updated example readme * Updated with-passport example * Updated profile page for with-passport * Updated with-passport-and-next-connect * Updated with-magic * Updated with-magic readme * Updated with-iron-session * Updated next version in with-iron-sessio...
examples/with-passport/lib/user.js
@@ -1,27 +1,46 @@ -// import crypto from 'crypto' +import crypto from 'crypto' +import { v4 as uuidv4 } from 'uuid' /** * User methods. The example doesn't contain a DB, but for real applications you must use a * db here, such as MongoDB, Fauna, SQL, etc. */ +const users = [] + export async function createU...
true