-
-
Notifications
You must be signed in to change notification settings - Fork 1.4k
Support subdirectory deployment and fix API path handling #311
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from 1 commit
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,27 +1,28 @@ | ||
| import type { MetadataRoute } from "next"; | ||
| import type { MetadataRoute } from "next" | ||
|
|
||
| export default function manifest(): MetadataRoute.Manifest { | ||
| return { | ||
| name: 'Next AI Draw.io', | ||
| short_name: 'AIDraw.io', | ||
| description: 'Create AWS architecture diagrams, flowcharts, and technical diagrams using AI. Free online tool integrating draw.io with AI assistance for professional diagram creation.', | ||
| start_url: '/', | ||
| display: 'standalone', | ||
| background_color: '#f9fafb', | ||
| theme_color: '#171d26', | ||
| icons: [ | ||
| { | ||
| src: '/favicon-192x192.png', | ||
| sizes: '192x192', | ||
| type: 'image/png', | ||
| purpose: 'any', | ||
| }, | ||
| { | ||
| src: '/favicon-512x512.png', | ||
| sizes: '512x512', | ||
| type: 'image/png', | ||
| purpose: 'any', | ||
| }, | ||
| ], | ||
| } | ||
| return { | ||
| name: "Next AI Draw.io", | ||
| short_name: "AIDraw.io", | ||
| description: | ||
| "Create AWS architecture diagrams, flowcharts, and technical diagrams using AI. Free online tool integrating draw.io with AI assistance for professional diagram creation.", | ||
| start_url: process.env.NEXT_PUBLIC_BASE_PATH || "/", | ||
| display: "standalone", | ||
| background_color: "#f9fafb", | ||
| theme_color: "#171d26", | ||
| icons: [ | ||
| { | ||
| src: "/favicon-192x192.png", | ||
|
||
| sizes: "192x192", | ||
| type: "image/png", | ||
| purpose: "any", | ||
| }, | ||
| { | ||
| src: "/favicon-512x512.png", | ||
| sizes: "512x512", | ||
| type: "image/png", | ||
| purpose: "any", | ||
| }, | ||
| ], | ||
| } | ||
| } | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,38 @@ | ||
| /** | ||
| * Get the base path for API calls and static assets | ||
| * This is used for subdirectory deployment support | ||
| * | ||
| * Example: If deployed at https://example.com/nextaidrawio, this returns "/nextaidrawio" | ||
| * For root deployment, this returns "" | ||
| * | ||
| * Set NEXT_PUBLIC_BASE_PATH environment variable to your subdirectory path (e.g., /nextaidrawio) | ||
| */ | ||
| export function getBasePath(): string { | ||
| // Only available on client side | ||
| if (typeof window === "undefined") { | ||
|
||
| return "" | ||
| } | ||
|
|
||
| // Read from environment variable (must start with NEXT_PUBLIC_ to be available on client) | ||
| return process.env.NEXT_PUBLIC_BASE_PATH || "" | ||
| } | ||
|
|
||
| /** | ||
| * Get full API endpoint URL | ||
| * @param endpoint - API endpoint path (e.g., "/api/chat", "/api/config") | ||
| * @returns Full API path with base path prefix | ||
| */ | ||
| export function getApiEndpoint(endpoint: string): string { | ||
| const basePath = getBasePath() | ||
| return `${basePath}${endpoint}` | ||
| } | ||
|
|
||
| /** | ||
| * Get full static asset URL | ||
| * @param assetPath - Asset path (e.g., "/example.png", "/chain-of-thought.txt") | ||
| * @returns Full asset path with base path prefix | ||
| */ | ||
| export function getAssetUrl(assetPath: string): string { | ||
| const basePath = getBasePath() | ||
| return `${basePath}${assetPath}` | ||
| } | ||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I realized that it is better to use
getAssetUrl("/favicon-192x192.png")sinceprocess.env.NEXT_PUBLIC_BASE_PATHcan be undefine.Also for line 15