Skip to content

basePath not working after updating to 10.0.8 #22843

@violabg

Description

@violabg

What version of Next.js are you using?

10.0.8

What version of Node.js are you using?

14

What browser are you using?

Chrome, Safari

What operating system are you using?

macOs 11.2.2

How are you deploying your application?

next start

Describe the Bug

I've updated to 10.0.8, and basePath stoped working I'm getting:

 http://localhost:3000/brand/it 404 (Not Found)
it:1 GET http://localhost:3000/brand/_next/static/chunks/main-093be8720c3bcc128712.js net::ERR_ABORTED 404 (Not Found)
it:1 GET http://localhost:3000/brand/_next/static/chunks/commons.1869cbd23f3f8cc4be00.js net::ERR_ABORTED 404 (Not Found)
it:1 GET http://localhost:3000/brand/_next/static/chunks/pages/_error-4c1af142aef0a484e71f.js net::ERR_ABORTED 404 (Not Found)
it:1 GET http://localhost:3000/brand/fonts/styles.css net::ERR_ABORTED 404 (Not Found)
it:25 GET http://localhost:3000/brand/_next/static/2tJDBmRSU0I806yikZrLc/_buildManifest.js net::ERR_ABORTED 404 (Not Found)
it:25 GET http://localhost:3000/brand/_next/static/2tJDBmRSU0I806yikZrLc/_ssgManifest.js net::ERR_ABORTED 404 (Not Found)
it:25 GET http://localhost:3000/brand/chat.js net::ERR_ABORTED 404 (Not Found)
it:25 GET http://localhost:3000/brand/brand-dark-bg.png 404 (Not Found)
it:25 GET http://localhost:3000/brand/_next/static/chunks/main-093be8720c3bcc128712.js net::ERR_ABORTED 404 (Not Found)
it:25 GET http://localhost:3000/brand/_next/static/chunks/commons.1869cbd23f3f8cc4be00.js net::ERR_ABORTED 404 (Not Found)
it:25 GET http://localhost:3000/brand/_next/static/chunks/pages/_error-4c1af142aef0a484e71f.js net::ERR_ABORTED 404 (Not Found)
it:25 GET http://localhost:3000/brand/_next/static/2tJDBmRSU0I806yikZrLc/_buildManifest.js net::ERR_ABORTED 404 (Not Found)
it:25 GET http://localhost:3000/brand/_next/static/2tJDBmRSU0I806yikZrLc/_ssgManifest.js net::ERR_ABORTED 404 (Not Found)
favicon-brand.ico:1 GET http://localhost:3000/brand/favicon/favicon-brand.ico 404 (Not Found)

Expected Behavior

to be able to load scripts via basePath

To Reproduce

/* eslint-disable @typescript-eslint/no-var-requires */
const dotenv = require("dotenv");
const fs = require("fs");
const path = require("path");
const nextTranslate = require("next-translate");

dotenv.config();
const domain = process.env["NEXT_PUBLIC_SERVER_DOMAIN"];
const secretCookiePassword = process.env["SECRET_COOKIE_PASSWORD"];
const endpoint = process.env.NEXT_PUBLIC_GQL_API_DOMAIN;
const dip = process.env.NEXT_PUBLIC_DIP_DOMAIN;
const trackingID = process.env.NEXT_PUBLIC_TRACKING_ID ?? "UA-190484440-1";
const brand = process.env.NEXT_PUBLIC_BRAND;
const isProd = process.env.NODE_ENV === "production";

module.exports = nextTranslate({
  basePath: isProd ? `/${brand}` : "",
  env: {
    NEXT_PUBLIC_SERVER_DOMAIN: domain,
    SECRET_COOKIE_PASSWORD: secretCookiePassword,
    NEXT_PUBLIC_BRAND: brand,
    NEXT_PUBLIC_GQL_API_DOMAIN: endpoint,
    NEXT_PUBLIC_DIP_DOMAIN: dip,
    NEXT_PUBLIC_TRACKING_ID: trackingID
  },
  images: {
    domains: ["mydomain.com"]
  }
});

it was working fine since 10.0.7. It still works on dev mode, but when I build and start the project either on localhost or on production server, it stop working.

I hade problem with environmental variable not been read on browser after updating to 10.0.8, that I solved by prefixing them with NEXT_PUBLIC_.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugIssue was opened via the bug report template.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions