Fix: Versionsanzeige im Footer - Git-Tags während Docker-Build verfügbar machen und Fallbacks hinzufügen
This commit is contained in:
@@ -15,7 +15,7 @@ export async function GET() {
|
||||
for (const versionFilePath of versionPaths) {
|
||||
if (existsSync(versionFilePath)) {
|
||||
const version = readFileSync(versionFilePath, 'utf-8').trim();
|
||||
if (version && version !== 'unknown') {
|
||||
if (version && version !== 'unknown' && version !== '') {
|
||||
return NextResponse.json({ version });
|
||||
}
|
||||
}
|
||||
@@ -26,6 +26,19 @@ export async function GET() {
|
||||
return NextResponse.json({ version: process.env.APP_VERSION });
|
||||
}
|
||||
|
||||
// Fallback: check package.json
|
||||
try {
|
||||
const packageJsonPath = join(process.cwd(), 'package.json');
|
||||
if (existsSync(packageJsonPath)) {
|
||||
const packageJson = JSON.parse(readFileSync(packageJsonPath, 'utf-8'));
|
||||
if (packageJson.version) {
|
||||
return NextResponse.json({ version: `v${packageJson.version}` });
|
||||
}
|
||||
}
|
||||
} catch {
|
||||
// Ignore package.json read errors
|
||||
}
|
||||
|
||||
// Fallback: try to get from git (local development)
|
||||
let version = 'dev';
|
||||
|
||||
|
||||
Reference in New Issue
Block a user