@netlify/plugin-nextjs
Advanced tools
Comparing version 5.7.4 to 5.8.0
@@ -21,2 +21,3 @@ | ||
async function getAPIRoutesConfigs(ctx) { | ||
const uniqueApiRoutes = /* @__PURE__ */ new Set(); | ||
const functionsConfigManifestPath = join( | ||
@@ -27,8 +28,22 @@ ctx.publishDir, | ||
); | ||
if (!existsSync(functionsConfigManifestPath)) { | ||
if (existsSync(functionsConfigManifestPath)) { | ||
const functionsConfigManifest = JSON.parse( | ||
await readFile(functionsConfigManifestPath, "utf-8") | ||
); | ||
for (const apiRoute of Object.keys(functionsConfigManifest.functions)) { | ||
uniqueApiRoutes.add(apiRoute); | ||
} | ||
} | ||
const pagesManifestPath = join(ctx.publishDir, "server", "pages-manifest.json"); | ||
if (existsSync(pagesManifestPath)) { | ||
const pagesManifest = JSON.parse(await readFile(pagesManifestPath, "utf-8")); | ||
for (const route of Object.keys(pagesManifest)) { | ||
if (route.startsWith("/api/")) { | ||
uniqueApiRoutes.add(route); | ||
} | ||
} | ||
} | ||
if (uniqueApiRoutes.size === 0) { | ||
return []; | ||
} | ||
const functionsConfigManifest = JSON.parse( | ||
await readFile(functionsConfigManifestPath, "utf-8") | ||
); | ||
const appDir = ctx.resolveFromSiteDir("."); | ||
@@ -39,3 +54,3 @@ const pagesDir = join(appDir, "pages"); | ||
return Promise.all( | ||
Object.keys(functionsConfigManifest.functions).map(async (apiRoute) => { | ||
[...uniqueApiRoutes].map(async (apiRoute) => { | ||
const filePath = getSourceFileForPage(apiRoute, [pagesDir, srcPagesDir], pageExtensions); | ||
@@ -42,0 +57,0 @@ const sharedFields = { |
@@ -45,3 +45,3 @@ | ||
var getHeaderValueArray = (header) => { | ||
return header.split(",").map((value) => value.trim()); | ||
return header.split(",").map((value) => value.trim()).filter(Boolean); | ||
}; | ||
@@ -146,3 +146,3 @@ var omitHeaderValues = (header, values) => { | ||
}; | ||
var setCacheControlHeaders = (headers, request, requestContext) => { | ||
var setCacheControlHeaders = ({ headers, status }, request, requestContext) => { | ||
if (typeof requestContext.routeHandlerRevalidate !== "undefined" && ["GET", "HEAD"].includes(request.method) && !headers.has("cdn-cache-control") && !headers.has("netlify-cdn-cache-control")) { | ||
@@ -156,2 +156,6 @@ const cdnCacheControl = ( | ||
} | ||
if (status === 404 && request.url.endsWith(".php")) { | ||
headers.set("cache-control", "public, max-age=0, must-revalidate"); | ||
headers.set("netlify-cdn-cache-control", `max-age=31536000, durable`); | ||
} | ||
const cacheControl = headers.get("cache-control"); | ||
@@ -158,0 +162,0 @@ if (cacheControl !== null && ["GET", "HEAD"].includes(request.method) && !headers.has("cdn-cache-control") && !headers.has("netlify-cdn-cache-control")) { |
{ | ||
"name": "@netlify/plugin-nextjs", | ||
"version": "5.7.4", | ||
"version": "5.8.0", | ||
"description": "Run Next.js seamlessly on Netlify", | ||
@@ -5,0 +5,0 @@ "main": "./dist/index.js", |
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is too big to display
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
5303405
138785