Skip to content

Open-source status page, incident response and uptime monitoring

fix: https

Maximilian Kaske85cb29e839bb
diff --git a/apps/web/next.config.js b/apps/web/next.config.js
index 5ba4640da..aa1f7f798 100644
--- a/apps/web/next.config.js
+++ b/apps/web/next.config.js
@@ -65,8 +65,9 @@ const nextConfig = {
];
},
async rewrites() {
- const NEW_HOST =
+ const HOST =
process.env.NODE_ENV === "development" ? "localhost:3001" : "stpg.dev";
+ const PROTOCOL = process.env.NODE_ENV === "development" ? "http" : "https";
return {
beforeFiles: [
// Proxy app subdomain to /app
@@ -90,7 +91,7 @@ const nextConfig = {
value: "(?<slug>[^.]+)\\.(openstatus\\.dev|localhost)",
},
],
- destination: `http://${NEW_HOST}/_next/:path*`,
+ destination: `${PROTOCOL}://${HOST}/_next/:path*`,
},
// New design: proxy app routes to external host with slug prefix
{
@@ -103,7 +104,7 @@ const nextConfig = {
},
],
// NOTE: might be different on prod and localhost (without :slug)
- destination: `http://${NEW_HOST}/:slug/:path*`,
+ destination: `${PROTOCOL}://${HOST}/:slug/:path*`,
},
],
};
@@ -137,5 +138,5 @@ module.exports = withSentryConfig(
// Automatically tree-shake Sentry logger statements to reduce bundle size
disableLogger: true,
- }
+ },
);
diff --git a/apps/web/src/middleware.ts b/apps/web/src/middleware.ts
index 74cb6ed86..fce2562fe 100644
--- a/apps/web/src/middleware.ts
+++ b/apps/web/src/middleware.ts
@@ -78,9 +78,11 @@ export default auth(async (req) => {
try {
const redis = Redis.fromEnv();
const cache = await redis.get(`page:${subdomain}`);
+ console.log({ cache });
// Determine legacy flag from cache
mode = cache ? "new" : "legacy";
} catch {
+ console.log("error getting cache");
mode = "legacy";
}
}
@@ -110,15 +112,15 @@ export default auth(async (req) => {
}
const isPublicAppPath = publicAppPaths.some((path) =>
- pathname.startsWith(path)
+ pathname.startsWith(path),
);
if (!req.auth && pathname.startsWith("/app/invite")) {
return NextResponse.redirect(
new URL(
`/app/login?redirectTo=${encodeURIComponent(req.nextUrl.href)}`,
- req.url
- )
+ req.url,
+ ),
);
}
@@ -126,8 +128,8 @@ export default auth(async (req) => {
return NextResponse.redirect(
new URL(
`/app/login?redirectTo=${encodeURIComponent(req.nextUrl.href)}`,
- req.url
- )
+ req.url,
+ ),
);
}
@@ -146,7 +148,7 @@ export default auth(async (req) => {
if (hasWorkspaceSlug) {
const hasAccessToWorkspace = allowedWorkspaces.find(
- ({ workspace }) => workspace.slug === workspaceSlug
+ ({ workspace }) => workspace.slug === workspaceSlug,
);
if (hasAccessToWorkspace) {
const workspaceCookie = req.cookies.get("workspace-slug")?.value;
@@ -164,7 +166,7 @@ export default auth(async (req) => {
const firstWorkspace = allowedWorkspaces[0].workspace;
const { slug } = firstWorkspace;
return NextResponse.redirect(
- new URL(`/app/${slug}/monitors`, req.url)
+ new URL(`/app/${slug}/monitors`, req.url),
);
}
}