Skip to content

Conversation

@Biki-dev
Copy link
Collaborator

@Biki-dev Biki-dev commented Dec 18, 2025

Summary

This PR adds support for deploying the app under a subdirectory by introducing the NEXT_PUBLIC_BASE_PATH configuration and updating client-side asset and API requests to respect the base path.

Changes

  • Added basePath to next.config.ts (reads NEXT_PUBLIC_BASE_PATH)
  • New utility lib/base-path.ts with getApiEndpoint() and getAssetUrl()
  • Updated client-side API calls to use getApiEndpoint()
  • Updated static asset usage to use getAssetUrl()

resolves #301

@vercel
Copy link

vercel bot commented Dec 18, 2025

@Biki-dev is attempting to deploy a commit to the dayuanjiang's projects Team on Vercel.

A member of the Team first needs to authorize it.

@DayuanJiang
Copy link
Owner

Hey, noticed #313 is working on the same feature. Would you two like to collaborate? @Biki-dev's utility approach + @zhangxin-github's about page coverage could make a more complete solution.

Copy link
Owner

@DayuanJiang DayuanJiang left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the contribution. I've added some inline comments—please take a look.

lib/base-path.ts Outdated
*/
export function getBasePath(): string {
// Only available on client side
if (typeof window === "undefined") {
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why is this check needed?

Copy link
Collaborator Author

@Biki-dev Biki-dev Dec 18, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Because window does not exist on the server, the check typeof window === "undefined" is there to prevent errors during SSR.If you want the function to function the same on both the server and the client, it can be remove also. The environment variable is available during build/SSR time.

app/manifest.ts Outdated
theme_color: "#171d26",
icons: [
{
src: "/favicon-192x192.png",
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The icon path alse need be updated with the basePath

@Biki-dev
Copy link
Collaborator Author

Hey, noticed #313 is working on the same feature. Would you two like to collaborate? @Biki-dev's utility approach + @zhangxin-github's about page coverage could make a more complete solution.

@DayuanJiang sure

@Biki-dev Biki-dev requested a review from DayuanJiang December 18, 2025 13:32
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

请问能否支持子目录部署?

2 participants