-
Notifications
You must be signed in to change notification settings - Fork 16
/
Copy pathnext.config.mjs
141 lines (135 loc) · 5.27 KB
/
next.config.mjs
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
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
// next.config.mjs
/** @type {import('next').NextConfig} */
import nextI18nextConfig from "./next-i18next.config.js";
import { NextFederationPlugin } from "@module-federation/nextjs-mf";
const url = process.env.NEXT_PUBLIC_WORKSPACE_BASE_URL;
// const url = "http://localhost:3000";
const remotes = (isServer) => {
const location = isServer ? "ssr" : "chunks";
return {
editor: `editor@${url}/_next/static/${location}/remoteEntry.js`,
};
};
const PORTAL_BASE_URL = "https://sunbird-editor.tekdinext.com";
const routes = {
API: {
GENERAL: {
CONTENT_PREVIEW: "/content/preview/:path*",
CONTENT_PLUGINS: "/content-plugins/:path*",
GENERIC_EDITOR: "/generic-editor/:path*",
},
},
};
const nextConfig = {
eslint: {
// Disabling on production builds because we're running checks on PRs via GitHub Actions.
ignoreDuringBuilds: true,
},
trailingSlash: false,
reactStrictMode: true,
i18n: nextI18nextConfig.i18n,
distDir: "build",
images: {
unoptimized: true,
},
reactStrictMode: true,
experimental: {
esmExternals: false,
},
async rewrites() {
return [
{
source: "/action/asset/v1/upload/:identifier*", // Match asset upload routes
destination: "/api/fileUpload", // Forward asset uploads to fileUpload proxy
},
{
source: "/assets/pdfjs/:path*", // Match any URL starting with /workspace/content/assets/
destination: `${process.env.WORKSPACE_BASE_URL}/assets/pdfjs/:path*`, // Serve the assets from the public folder
},
{
source: "/play/content/assets/pdfjs/:path*", // Match any URL starting with /workspace/content/assets/
destination: `${process.env.WORKSPACE_BASE_URL}/assets/pdfjs/:path*`, // Serve the assets from the public folder
},
{
source: "/play/content/assets/:path*", // Match any URL starting with /workspace/content/assets/
destination: `${process.env.WORKSPACE_BASE_URL}/assets/:path*`, // Serve the assets from the public folder
},
{
source: "/action/content/v3/upload/url/:identifier*", // Match content upload with 'url' in the path
destination: `${process.env.WORKSPACE_BASE_URL}/api/proxy?path=/action/content/v3/upload/url/:identifier*`, // Forward to proxy route with path as query param
},
{
source: "/action/content/v3/upload/:identifier*", // Match content upload routes
destination: "/api/fileUpload", // Forward asset uploads to fileUpload proxy
},
{
source: "/workspace/content/assets/:path*", // Match any URL starting with /workspace/content/assets/
destination: `${process.env.WORKSPACE_BASE_URL}/assets/:path*`, // Serve the assets from the public folder
},
{
source: "/action/asset/:path*", // Match other /action/asset routes
destination: `${process.env.WORKSPACE_BASE_URL}/api/proxy?path=/action/asset/:path*`, // Forward other /action/asset requests to proxy.js
},
{
source: "/action/v1/telemetry",
destination: `${process.env.NEXT_PUBLIC_TELEMETRY_URL}/v1/telemetry`,
},
{
source: "/action/data/v3/telemetry",
destination: `${process.env.NEXT_PUBLIC_TELEMETRY_URL}/v1/telemetry`,
},
{
source: "/data/v3/telemetry",
destination: `${process.env.NEXT_PUBLIC_TELEMETRY_URL}/v1/telemetry`,
},
{
source: "/action/content/:path*", // Match other /action/asset routes
destination: `${process.env.WORKSPACE_BASE_URL}/api/proxy?path=/action/content/:path*`, // Forward other /action/asset requests to proxy.js
},
{
source: "/action/:path*", // Match any other routes starting with /action/
destination: `${process.env.WORKSPACE_BASE_URL}/api/proxy?path=/action/:path*`, // Forward them to proxy.js
},
{
source: "/api/:path*", // Match /api/ routes
destination: `${process.env.WORKSPACE_BASE_URL}/api/proxy?path=/api/:path*`, // Forward them to proxy.js
},
{
source: "/assets/public/:path*", // Match any URL starting with /assets/public/
destination: `${process.env.CLOUD_STORAGE_URL}/:path*`, // Forward to workspace proxy
},
{
source: routes.API.GENERAL.CONTENT_PREVIEW,
destination: `${PORTAL_BASE_URL}${routes.API.GENERAL.CONTENT_PREVIEW}`, // Proxy to portal
},
{
source: routes.API.GENERAL.CONTENT_PLUGINS,
destination: `${PORTAL_BASE_URL}${routes.API.GENERAL.CONTENT_PLUGINS}`, // Proxy to portal
},
{
source: routes.API.GENERAL.GENERIC_EDITOR,
destination: `${PORTAL_BASE_URL}/:path*`, // Proxy to generic editor portal
},
{
source: '/sunbird-plugins/renderer/:path*',
destination: `${process.env.WORKSPACE_BASE_URL}/sunbird-plugins/renderer/:path*`
},
{
source: "/app/telemetry", // Match telemetry route
destination: `${process.env.WORKSPACE_BASE_URL}/api/telemetry`, // Redirect to telemetry proxy
},
];
},
webpack: (config, { isServer }) => {
config.plugins.push(
new NextFederationPlugin({
name: "admin",
filename: "static/chunks/remoteEntry.js",
remotes: remotes(isServer),
exposes: {},
})
);
return config;
},
};
export default nextConfig;