Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@netlify/plugin-nextjs

Package Overview
Dependencies
Maintainers
19
Versions
261
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@netlify/plugin-nextjs - npm Package Compare versions

Comparing version 5.0.0-beta.8 to 5.0.0-beta.9

dist/esm-chunks/chunk-4J4A5OE2.js

2

dist/build/cache.js

@@ -10,3 +10,3 @@

saveBuildCache
} from "../esm-chunks/chunk-XA2CZH5Y.js";
} from "../esm-chunks/chunk-72ZI2IVI.js";
import "../esm-chunks/chunk-5JVNISGM.js";

@@ -13,0 +13,0 @@ export {

@@ -10,4 +10,5 @@

copyPrerenderedContent
} from "../../esm-chunks/chunk-XFDUV7DP.js";
} from "../../esm-chunks/chunk-67EWAGDQ.js";
import "../../esm-chunks/chunk-VZNKO4OO.js";
import "../../esm-chunks/chunk-TYCYFZ22.js";
import "../../esm-chunks/chunk-5JVNISGM.js";

@@ -14,0 +15,0 @@ export {

@@ -11,4 +11,5 @@

writeTagsManifest
} from "../../esm-chunks/chunk-YMFYCTRI.js";
} from "../../esm-chunks/chunk-4J4A5OE2.js";
import "../../esm-chunks/chunk-VZNKO4OO.js";
import "../../esm-chunks/chunk-UYKENJEU.js";
import "../../esm-chunks/chunk-5JVNISGM.js";

@@ -15,0 +16,0 @@ export {

@@ -9,6 +9,5 @@

createEdgeHandlers
} from "../../esm-chunks/chunk-ETPYUOBQ.js";
import "../../esm-chunks/chunk-IZ2AVCVF.js";
} from "../../esm-chunks/chunk-YIE34LVX.js";
import "../../esm-chunks/chunk-VZNKO4OO.js";
import "../../esm-chunks/chunk-TYCYFZ22.js";
import "../../esm-chunks/chunk-DWC6JSN7.js";
import "../../esm-chunks/chunk-5JVNISGM.js";

@@ -15,0 +14,0 @@ export {

@@ -9,7 +9,7 @@

createServerHandler
} from "../../esm-chunks/chunk-WSPFUAK4.js";
import "../../esm-chunks/chunk-YMFYCTRI.js";
import "../../esm-chunks/chunk-IZ2AVCVF.js";
} from "../../esm-chunks/chunk-T6AZTXZF.js";
import "../../esm-chunks/chunk-4J4A5OE2.js";
import "../../esm-chunks/chunk-VZNKO4OO.js";
import "../../esm-chunks/chunk-TYCYFZ22.js";
import "../../esm-chunks/chunk-DWC6JSN7.js";
import "../../esm-chunks/chunk-UYKENJEU.js";
import "../../esm-chunks/chunk-5JVNISGM.js";

@@ -16,0 +16,0 @@ export {

@@ -9,3 +9,3 @@

setImageConfig
} from "../esm-chunks/chunk-EPSI5TTB.js";
} from "../esm-chunks/chunk-TOK7TKP3.js";
import "../esm-chunks/chunk-5JVNISGM.js";

@@ -12,0 +12,0 @@ export {

@@ -11,4 +11,3 @@

SERVER_HANDLER_NAME
} from "../esm-chunks/chunk-IZ2AVCVF.js";
import "../esm-chunks/chunk-TYCYFZ22.js";
} from "../esm-chunks/chunk-DWC6JSN7.js";
import "../esm-chunks/chunk-5JVNISGM.js";

@@ -15,0 +14,0 @@ export {

@@ -1,2 +0,2 @@

import tracing, { trace } from '{{cwd}}/dist/run/handlers/tracing.js'
import tracing, { trace } from '{{cwd}}/.netlify/dist/run/handlers/tracing.js'

@@ -11,32 +11,35 @@ process.chdir('{{cwd}}')

return trace
.getTracer('Next.js Runtime')
.startActiveSpan('Next.js Server Handler', async (span) => {
try {
span.setAttributes({
'account.id': context.account.id,
'deploy.id': context.deploy.id,
'request.id': context.requestId,
'site.id': context.site.id,
'http.method': req.method,
'http.target': req.url,
monorepo: true,
cwd: '{{cwd}}',
})
if (!cachedHandler) {
const { default: handler } = await import('./{{nextServerHandler}}')
cachedHandler = handler
}
const response = await cachedHandler(req, context)
span.setAttributes({
'http.status_code': response.status,
})
return response
} catch (error) {
span.recordException(error)
throw error
} finally {
span.end()
/** @type {import('@opentelemetry/api').Tracer} */
const tracer = trace.getTracer('Next.js Runtime')
return tracer.startActiveSpan('Next.js Server Handler', async (span) => {
try {
span.setAttributes({
'account.id': context.account.id,
'deploy.id': context.deploy.id,
'request.id': context.requestId,
'site.id': context.site.id,
'http.method': req.method,
'http.target': req.url,
monorepo: true,
cwd: '{{cwd}}',
})
if (!cachedHandler) {
const { default: handler } = await import('{{nextServerHandler}}')
cachedHandler = handler
}
})
const response = await cachedHandler(req, context)
span.setAttributes({
'http.status_code': response.status,
})
return response
} catch (error) {
span.recordException(error)
if (error instanceof Error) {
span.addEvent({ name: error.name, message: error.message })
}
throw error
} finally {
span.end()
}
})
}

@@ -43,0 +46,0 @@

@@ -1,3 +0,3 @@

import serverHandler from './dist/run/handlers/server.js'
import tracing, { trace } from './dist/run/handlers/tracing.js'
import serverHandler from './.netlify/dist/run/handlers/server.js'
import tracing, { trace } from './.netlify/dist/run/handlers/tracing.js'

@@ -8,26 +8,32 @@ export default async function handler(req, context) {

}
return trace
.getTracer('Next.js Runtime')
.startActiveSpan('Next.js Server Handler', async (span) => {
try {
span.setAttributes({
'account.id': context.account.id,
'deploy.id': context.deploy.id,
'request.id': context.requestId,
'site.id': context.site.id,
'http.method': req.method,
'http.target': req.url,
})
const response = await serverHandler(req, context)
span.setAttributes({
'http.status_code': response.status,
})
return response
} catch (error) {
span.recordException(error)
throw error
} finally {
span.end()
/** @type {import('@opentelemetry/api').Tracer} */
const tracer = trace.getTracer('Next.js Runtime')
return tracer.startActiveSpan('Next.js Server Handler', async (span) => {
try {
span.setAttributes({
'account.id': context.account.id,
'deploy.id': context.deploy.id,
'request.id': context.requestId,
'site.id': context.site.id,
'http.method': req.method,
'http.target': req.url,
monorepo: false,
cwd: process.cwd(),
})
const response = await serverHandler(req, context)
span.setAttributes({
'http.status_code': response.status,
})
return response
} catch (error) {
span.recordException(error)
if (error instanceof Error) {
span.addEvent({ name: error.name, message: error.message })
}
})
throw error
} finally {
span.end()
}
})
}

@@ -34,0 +40,0 @@

@@ -8,9 +8,4 @@

import {
createServerHandler
} from "./esm-chunks/chunk-WSPFUAK4.js";
import {
copyFetchContent,
copyPrerenderedContent
} from "./esm-chunks/chunk-XFDUV7DP.js";
import "./esm-chunks/chunk-YMFYCTRI.js";
} from "./esm-chunks/chunk-67EWAGDQ.js";
import {

@@ -24,15 +19,20 @@ copyStaticAssets,

createEdgeHandlers
} from "./esm-chunks/chunk-ETPYUOBQ.js";
} from "./esm-chunks/chunk-YIE34LVX.js";
import {
PluginContext
} from "./esm-chunks/chunk-IZ2AVCVF.js";
createServerHandler
} from "./esm-chunks/chunk-T6AZTXZF.js";
import "./esm-chunks/chunk-4J4A5OE2.js";
import "./esm-chunks/chunk-VZNKO4OO.js";
import "./esm-chunks/chunk-TYCYFZ22.js";
import {
restoreBuildCache,
saveBuildCache
} from "./esm-chunks/chunk-XA2CZH5Y.js";
} from "./esm-chunks/chunk-72ZI2IVI.js";
import {
setImageConfig
} from "./esm-chunks/chunk-EPSI5TTB.js";
} from "./esm-chunks/chunk-TOK7TKP3.js";
import {
PluginContext
} from "./esm-chunks/chunk-DWC6JSN7.js";
import "./esm-chunks/chunk-UYKENJEU.js";
import "./esm-chunks/chunk-TYCYFZ22.js";
import "./esm-chunks/chunk-5JVNISGM.js";

@@ -63,3 +63,2 @@

copyPrerenderedContent(ctx),
copyFetchContent(ctx),
createServerHandler(ctx),

@@ -66,0 +65,0 @@ createEdgeHandlers(ctx)

@@ -11,4 +11,4 @@

setRunConfig
} from "../esm-chunks/chunk-XIP2W57K.js";
import "../esm-chunks/chunk-K233JI4O.js";
} from "../esm-chunks/chunk-NL5YH5N6.js";
import "../esm-chunks/chunk-UYKENJEU.js";
import "../esm-chunks/chunk-5JVNISGM.js";

@@ -15,0 +15,0 @@ export {

@@ -9,8 +9,10 @@

MODULE_DIR,
PLUGIN_DIR
} from "../esm-chunks/chunk-K233JI4O.js";
PLUGIN_DIR,
RUN_CONFIG
} from "../esm-chunks/chunk-UYKENJEU.js";
import "../esm-chunks/chunk-5JVNISGM.js";
export {
MODULE_DIR,
PLUGIN_DIR
PLUGIN_DIR,
RUN_CONFIG
};

@@ -9,7 +9,7 @@

adjustDateHeader,
handleNextCacheHeader,
setCacheControlHeaders,
setCacheStatusHeader,
setCacheTagsHeaders,
setVaryHeaders
} from "../esm-chunks/chunk-N23TUUXK.js";
} from "../esm-chunks/chunk-AU7XDLZH.js";
import "../esm-chunks/chunk-TYCYFZ22.js";

@@ -19,6 +19,6 @@ import "../esm-chunks/chunk-5JVNISGM.js";

adjustDateHeader,
handleNextCacheHeader,
setCacheControlHeaders,
setCacheStatusHeader,
setCacheTagsHeaders,
setVaryHeaders
};

@@ -10,4 +10,4 @@ import type { Context } from '@netlify/edge-functions'

normalizeLocalePath,
normalizeTrailingSlash,
relativizeURL,
rewriteDataPath,
} from './util.ts'

@@ -120,6 +120,17 @@ import { addMiddlewareHeaders, isMiddlewareRequest, isMiddlewareResponse } from './middleware.ts'

const rewrite = res.headers.get('x-middleware-rewrite')
let rewrite = res.headers.get('x-middleware-rewrite')
let redirect = res.headers.get('location')
// Data requests (i.e. requests for /_next/data ) need special handling
const isDataReq = request.headers.has('x-nextjs-data')
// Data requests need to be normalized to the route path
if (isDataReq && !redirect && !rewrite) {
const requestUrl = new URL(request.url)
const normalizedDataUrl = normalizeDataUrl(requestUrl.pathname)
// Don't rewrite unless the URL has changed
if (normalizedDataUrl !== requestUrl.pathname) {
rewrite = `${normalizedDataUrl}${requestUrl.search}`
logger.withFields({ rewrite_url: rewrite }).debug('Rewritten data URL')
}
}

@@ -137,3 +148,2 @@ if (rewrite) {

const relativeUrl = relativizeURL(rewrite, request.url)
const originalPath = new URL(request.url, `http://n`).pathname

@@ -169,17 +179,13 @@ if (isDataReq) {

}
return addMiddlewareHeaders(fetch(proxyRequest), res)
} else if (isDataReq) {
rewriteUrl.pathname = rewriteDataPath({
dataUrl: originalPath,
newRoute: rewriteUrl.pathname,
basePath: nextConfig?.basePath,
})
if (rewriteUrl.toString() === request.url) {
logger.withFields({ rewrite_url: rewrite }).debug('Rewrite url is same as original url')
return
}
res.headers.set('x-middleware-rewrite', relativeUrl)
return addMiddlewareHeaders(fetch(new Request(rewriteUrl, request)), res)
return addMiddlewareHeaders(fetch(proxyRequest, { redirect: 'manual' }), res)
}
const target = normalizeLocalizedTarget({ target: rewrite, request, nextConfig })
if (isDataReq) {
// The rewrite target is a data request, but a middleware rewrite target is always for the page route,
// so we need to tell the server this is a data request. Setting the `x-nextjs-data` header is not enough. 🤷
rewriteUrl.searchParams.set('__nextDataReq', '1')
rewriteUrl.pathname = normalizeTrailingSlash(rewriteUrl.pathname, nextConfig?.trailingSlash)
}
const target = normalizeLocalizedTarget({ target: rewriteUrl.toString(), request, nextConfig })
if (target === request.url) {

@@ -191,7 +197,5 @@ logger.withFields({ rewrite_url: rewrite }).debug('Rewrite url is same as original url')

request.headers.set('x-middleware-rewrite', target)
return addMiddlewareHeaders(fetch(new Request(target, request)), res)
return addMiddlewareHeaders(context.rewrite(target), res)
}
let redirect = res.headers.get('location')
// If we are redirecting a request that had a locale in the URL, we need to add it back in

@@ -198,0 +202,0 @@ if (redirect && requestLocale) {

@@ -84,5 +84,10 @@ import type { RequestData } from './next-request.ts'

const stripTrailingSlash = (path: string) =>
export const normalizeTrailingSlash = (path: string, trailingSlash?: boolean) =>
trailingSlash ? addTrailingSlash(path) : stripTrailingSlash(path)
export const stripTrailingSlash = (path: string) =>
path !== '/' && path.endsWith('/') ? path.slice(0, -1) : path
export const addTrailingSlash = (path: string) => (path.endsWith('/') ? path : `${path}/`)
/**

@@ -89,0 +94,0 @@ * Modify a data url to point to a new page route.

{
"name": "@netlify/plugin-nextjs",
"version": "5.0.0-beta.8",
"version": "5.0.0-beta.9",
"description": "Run Next.js seamlessly on Netlify",

@@ -5,0 +5,0 @@ "main": "./dist/index.js",

@@ -6,2 +6,25 @@ # Next.js Runtime

## Lambda Folder structure:
For a simple next.js app
```
/___netlify-server-handler
├── .netlify
│ ├── tags-manifest.json
│ └── dist // the compiled runtime code
│ └── run
│ ├── handlers
│ │ ├── server.js
│ │ └── cache.cjs
│ └── next.cjs
├── .next // or distDir name from the next.config.js
│ └── // content from standalone
├── run-config.json // the config object from the required-server-files.json
├── node_modules
├── ___netlify-server-handler.json
├── ___netlify-server-handler.mjs
└── package.json
```
## Testing

@@ -8,0 +31,0 @@

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is too big to display

Sorry, the diff of this file is too big to display

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc