question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Custom server buildId missing

See original GitHub issue

What version of Next.js are you using?

12.0.7

What version of Node.js are you using?

16.13.1

What browser are you using?

chrome

What operating system are you using?

ubuntu server

How are you deploying your application?

custom

Describe the Bug

Trying to use build id on a custom server (for assetPrefix) but seems like it was removed so now I’m not able to use it as it was moved under server which is private.

export declare class NextServer {
    private serverPromise?;
    private server?;
    private reqHandlerPromise?;
    private preparedAssetPrefix?;
    options: NextServerOptions;
    constructor(options: NextServerOptions);
    get hostname(): string | undefined;
    get port(): number | undefined;
    getRequestHandler(): RequestHandler;
    setAssetPrefix(assetPrefix: string): void;
    logError(...args: Parameters<Server['logError']>): void;
    render(...args: Parameters<Server['render']>): Promise<void>;
    renderToHTML(...args: Parameters<Server['renderToHTML']>): Promise<string | null>;
    renderError(...args: Parameters<Server['renderError']>): Promise<void>;
    renderErrorToHTML(...args: Parameters<Server['renderErrorToHTML']>): Promise<string | null>;
    render404(...args: Parameters<Server['render404']>): Promise<void>;
    serveStatic(...args: Parameters<Server['serveStatic']>): Promise<void>;
    prepare(): Promise<void>;
    close(): Promise<any>;
    private createServer;
    private loadConfig;
    private getServer;
    private getServerRequestHandler;
}

Expected Behavior

Maybe have a public builId ?

To Reproduce

const app = next({ dev });
app.prepare().then(() => {
  if (process.env.CDN_PATH) {
    app.setAssetPrefix(`${process.env.CDN_PATH}/${app.buildId}/`);
});

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Comments:9 (5 by maintainers)

github_iconTop GitHub Comments

1reaction
jpmarracommented, Jan 18, 2022

Now that Server is wrapped by NextServer and is a private variable, we are unable to access buildId without ignoring the TS error. This is true for all of the previously public Server values, like the router which houses dynamicRoutes.

Many of these things are necessary in order to properly build out a custom server. Why were they made private?

1reaction
tonytothcommented, Dec 13, 2021

😐 Dude … I’m talking about about a Typescript interface and you close this topic without understanding the issue … Then you show me JS code …

Read more comments on GitHub >

github_iconTop Results From Across the Web

Configuring the Build ID - Next.js
Configure the build id, which is used to identify the current build in which your application is being served.
Read more >
How to get a BuildID from a SessionId? - Playfab Community
If there's something I'm missing, then, how can I retrieve the BuildId based on the SessionId? ... MatchmakingCustom Game Servers. Comment.
Read more >
RHEL8 rpmbuild and /usr/lib/.build-id - Red Hat Customer Portal
In RHEL7, I was able to separate my custom installations into /usr/local, keeping them well away from the official RH software.
Read more >
NextJS cannot find a valid build in the '.next' directory
Try building your app with 'next build' before starting the production server. https://nextjs.org/docs/messages/production-start-no-build-id.
Read more >
How To Deploy Next.js on Multiple Servers - Level Up Coding
In other terms, you may end up losing almost all the benefits coming ... As mentioned here, Next.js allows you to define a...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found