NextJS 14.x Standalone - Azure AppService - server.js corrupted
Answered
Filipino Venus posted this in #help-forum
Filipino VenusOP
Hello,
TLDR:
* using an older version of
* using the one generated by
I've been trying to deploy a Standalone build of NextJs 14.x
* Target Infra: Azure AppService Windows
* packages.json > engines> node: ">= 20.17.0"
* Build agent: NodeJS 20.17.0 (via
* Azure AppService: Node ~20 (via env var and checked via
* Tried
the build seems to be fine i'm properly doing:
I'm deploying using
which properly generate the
RESULT:
ERROR 500.1001 or 500.1002 on "could not find the file ... blalbabla"
though ... after using another
I'm diffed both
1: the
1.1: all string are now using
2: there's no more
3: the one working was before we changed from
here's the mjs file:
TLDR:
* using an older version of
server.js works (was build on a linux agent / was before mjs file)* using the one generated by
standalone build failsI've been trying to deploy a Standalone build of NextJs 14.x
* Target Infra: Azure AppService Windows
* packages.json > engines> node: ">= 20.17.0"
* Build agent: NodeJS 20.17.0 (via
.nvmrc) + tried Windows / Linux* Azure AppService: Node ~20 (via env var and checked via
node -v in remote shell)* Tried
next.config.js or .mjs same errorthe build seems to be fine i'm properly doing:
"build": "next build && cp -r .next/static .next/standalone/.next/; cp -r public .next/standalone/",I'm deploying using
WebConfigParameters: '-Handler iisnode -NodeStartFile server.js -appType node'which properly generate the
web.config with iisnode pointing to server.jsRESULT:
ERROR 500.1001 or 500.1002 on "could not find the file ... blalbabla"
though ... after using another
server.js from a linux build this works with literally (nearly) literally 0 changeI'm diffed both
server.js and here's what I found:1: the
const nextConfig now have all Key as string and not as JSON like before1.1: all string are now using
" and not ' anymore2: there's no more
; at the end ... should not matter3: the one working was before we changed from
next.config.js to next.config.mjs but after rolling back to .js the result is still KOhere's the mjs file:
import path from 'path';
/** @type {import('next').NextConfig} */
const nextConfig = {
output: 'standalone',
sassOptions: {
includePaths: [path.join(import.meta.dirname, 'styles')],
},
};
export default nextConfig;Answered by Filipino Venus
this is in fact a critical bug explained here:
#[standalone] Next 14.x broke namedpipe usage entirely
#[standalone] Next 14.x broke namedpipe usage entirely
5 Replies
Filipino VenusOP
ok so apparemently I had to
sed / string replace the server.js:- const currentPort = parseInt(process.env.PORT, 10) || 3000
+ const currentPort = process.env.PORT || 3000+ add
PORT to .envthis is completly insane
anybody knows why this would/could happen ?
Filipino VenusOP
this is in fact a critical bug explained here:
#[standalone] Next 14.x broke namedpipe usage entirely
#[standalone] Next 14.x broke namedpipe usage entirely
Answer