diff --git a/src/helpers/functions.ts b/src/helpers/functions.ts index 0e92fa28dc..34d40190fb 100644 --- a/src/helpers/functions.ts +++ b/src/helpers/functions.ts @@ -2,7 +2,7 @@ import { NetlifyConfig, NetlifyPluginConstants } from '@netlify/build' import bridgeFile from '@vercel/node-bridge' import { copyFile, ensureDir, writeFile, writeJSON } from 'fs-extra' import type { ImageConfigComplete } from 'next/dist/server/image-config' -import { join, relative } from 'pathe' +import { join, relative, resolve } from 'pathe' import { HANDLER_FUNCTION_NAME, ODB_FUNCTION_NAME, IMAGE_FUNCTION_NAME, DEFAULT_FUNCTIONS_SRC } from '../constants' import { getHandler } from '../templates/getHandler' @@ -14,7 +14,7 @@ export const generateFunctions = async ( ): Promise => { const functionsDir = INTERNAL_FUNCTIONS_SRC || FUNCTIONS_SRC const functionDir = join(process.cwd(), functionsDir, HANDLER_FUNCTION_NAME) - const publishDir = relative(functionDir, join(process.cwd(), PUBLISH_DIR)) + const publishDir = relative(functionDir, resolve(PUBLISH_DIR)) const writeHandler = async (func: string, isODB: boolean) => { const handlerSource = await getHandler({ isODB, publishDir, appDir: relative(functionDir, appDir) }) diff --git a/src/helpers/verification.ts b/src/helpers/verification.ts index caa91fbdbf..b879a65486 100644 --- a/src/helpers/verification.ts +++ b/src/helpers/verification.ts @@ -68,10 +68,7 @@ export const checkNextSiteHasBuilt = ({ : `In most cases it should be set to ".next", unless you have chosen a custom "distDir" in your Next config.` return failBuild(outdent` - The directory "${path.relative( - process.cwd(), - publish, - )}" does not contain a Next.js production build. Perhaps the build command was not run, or you specified the wrong publish directory. + The directory "${publish}" does not contain a Next.js production build. Perhaps the build command was not run, or you specified the wrong publish directory. ${outWarning} If you are using "next export" then you should set the environment variable NETLIFY_NEXT_PLUGIN_SKIP to "true". `) @@ -93,7 +90,7 @@ export const checkForRootPublish = ({ }): void | never => { if (path.resolve(publish) === path.resolve('.')) { failBuild(outdent` - Your publish directory is pointing to the base directory of your site. This is not supported for Next.js sites, and is probably a mistake. + Your publish directory is pointing to the base directory of your site. This is not supported for Next.js sites, and is probably a mistake. In most cases it should be set to ".next", unless you have chosen a custom "distDir" in your Next config, or the Next site is in a subdirectory. `) }