forked from need4deed-org/fe
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathnext.config.ts
More file actions
48 lines (44 loc) · 1.74 KB
/
Copy pathnext.config.ts
File metadata and controls
48 lines (44 loc) · 1.74 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
import { apiPrefix } from "@/config/constants";
import type { NextConfig } from "next";
const apiURL = process.env.API_URL || "http://localhost:5000";
// Keep in sync with the Dockerfile's NEXT_PUBLIC_CLOUDFRONT_URL default.
const DEFAULT_ASSET_URL = "https://d2nwrdddg8skub.cloudfront.net/images";
function assetHostname(): string {
const configured = process.env.NEXT_PUBLIC_CLOUDFRONT_URL;
// Set-but-empty would leave app code emitting root-relative image paths
// while this allowlist silently kept the default host.
if (configured !== undefined && configured.trim() === "") {
throw new Error("NEXT_PUBLIC_CLOUDFRONT_URL is set but empty");
}
const url = configured || DEFAULT_ASSET_URL;
try {
return new URL(url).hostname;
} catch {
throw new Error(`NEXT_PUBLIC_CLOUDFRONT_URL is not a valid URL: "${url}"`);
}
}
const nextConfig: NextConfig = {
typescript: { ignoreBuildErrors: true },
eslint: { ignoreDuringBuilds: true },
compiler: {
styledComponents: true,
},
async redirects() {
const eventPageDestination =
"https://docs.google.com/forms/d/e/1FAIpQLSft1xi4NrQB_O6-OyOvVm_HcDSzQtog_3MMj2XAIVNaLKEJxA/viewform?usp=dialog";
return [
{ source: "/event-page", destination: eventPageDestination, permanent: false },
{ source: "/event-page/", destination: eventPageDestination, permanent: false },
{ source: "/:lang/event-page", destination: eventPageDestination, permanent: false },
{ source: "/:lang/event-page/", destination: eventPageDestination, permanent: false },
];
},
async rewrites() {
return [{ source: `/${apiPrefix}/:path*`, destination: `${apiURL}/:path*` }];
},
images: {
domains: [assetHostname()],
},
output: "standalone",
};
export default nextConfig;