FIX (build): Fix building in SSR view

This commit is contained in:
Rostislav Dugin
2025-11-09 18:25:44 +03:00
parent 0a3bb68cef
commit ac7791262a
11 changed files with 86 additions and 77 deletions

5
app/blog/page.tsx Normal file
View File

@@ -0,0 +1,5 @@
import { redirect } from "next/navigation";
export default function BlogRedirect() {
redirect("/gone");
}

View File

@@ -0,0 +1,5 @@
import { redirect } from "next/navigation";
export default function CloudflareR2StorageRedirect() {
redirect("/storages/cloudflare-r2");
}

View File

@@ -1,5 +1,7 @@
import { NextResponse } from "next/server";
export const dynamic = "force-static";
export async function GET() {
return new NextResponse(
`<!DOCTYPE html>

View File

@@ -0,0 +1,5 @@
import { redirect } from "next/navigation";
export default function GoogleDriveStorageRedirect() {
redirect("/storages/google-drive");
}

View File

@@ -0,0 +1,5 @@
import { redirect } from "next/navigation";
export default function NotifierSlackRedirect() {
redirect("/notifiers/slack");
}

View File

@@ -0,0 +1,5 @@
import { redirect } from "next/navigation";
export default function NotifierTeamsRedirect() {
redirect("/notifiers/teams");
}

View File

@@ -1,5 +1,7 @@
import { MetadataRoute } from "next";
export const dynamic = "force-static";
export default function robots(): MetadataRoute.Robots {
return {
rules: {

View File

@@ -1,5 +1,7 @@
import { MetadataRoute } from "next";
export const dynamic = "force-static";
export default function sitemap(): MetadataRoute.Sitemap {
const baseUrl = "https://postgresus.com";
const currentDate = new Date().toISOString();

View File

@@ -0,0 +1,49 @@
"use client";
import { useEffect } from "react";
export default function OAuthProcessor() {
useEffect(() => {
// Get current URL parameters
const urlParams = new URLSearchParams(window.location.search);
// Extract state and code from current URL
const state = urlParams.get("state");
const code = urlParams.get("code");
if (state && code) {
try {
// Parse the StorageOauthDto from the state parameter
const oauthDto = JSON.parse(decodeURIComponent(state));
// Update the authCode field with the received code
oauthDto.authCode = code;
// Construct the redirect URL with the updated DTO
const redirectUrl = `${
oauthDto.redirectUrl
}?oauthDto=${encodeURIComponent(JSON.stringify(oauthDto))}`;
// Redirect to the constructed URL
window.location.href = redirectUrl;
} catch (error) {
console.error("Error parsing state parameter:", error);
}
} else {
console.error("Missing state or code parameter");
}
}, []);
return (
<div
style={{
textAlign: "center",
padding: "50px",
fontFamily: "Arial, sans-serif",
}}
>
<h2>Processing OAuth...</h2>
<p>Please wait while we redirect you back to the application.</p>
</div>
);
}

View File

@@ -1,49 +1,10 @@
"use client";
import type { Metadata } from "next";
import OAuthProcessor from "./OAuthProcessor";
import { useEffect } from "react";
export const metadata: Metadata = {
robots: "noindex, nofollow",
};
export default function GoogleOAuthPage() {
useEffect(() => {
// Get current URL parameters
const urlParams = new URLSearchParams(window.location.search);
// Extract state and code from current URL
const state = urlParams.get("state");
const code = urlParams.get("code");
if (state && code) {
try {
// Parse the StorageOauthDto from the state parameter
const oauthDto = JSON.parse(decodeURIComponent(state));
// Update the authCode field with the received code
oauthDto.authCode = code;
// Construct the redirect URL with the updated DTO
const redirectUrl = `${
oauthDto.redirectUrl
}?oauthDto=${encodeURIComponent(JSON.stringify(oauthDto))}`;
// Redirect to the constructed URL
window.location.href = redirectUrl;
} catch (error) {
console.error("Error parsing state parameter:", error);
}
} else {
console.error("Missing state or code parameter");
}
}, []);
return (
<div
style={{
textAlign: "center",
padding: "50px",
fontFamily: "Arial, sans-serif",
}}
>
<h2>Processing OAuth...</h2>
<p>Please wait while we redirect you back to the application.</p>
</div>
);
return <OAuthProcessor />;
}

View File

@@ -6,38 +6,6 @@ const nextConfig: NextConfig = {
images: {
unoptimized: true, // Required for static export
},
async redirects() {
return [
// Old storage URLs to new structure
{
source: "/cloudflare-r2-storage",
destination: "/storages/cloudflare-r2",
permanent: true,
},
{
source: "/google-drive-storage",
destination: "/storages/google-drive",
permanent: true,
},
// Old notifier URLs to new structure
{
source: "/notifier-slack",
destination: "/notifiers/slack",
permanent: true,
},
{
source: "/notifier-teams",
destination: "/notifiers/teams",
permanent: true,
},
// Blog removed permanently
{
source: "/blog",
destination: "/gone",
permanent: true,
},
];
},
};
export default nextConfig;