Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 28 additions & 0 deletions app/robots.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
import type { MetadataRoute } from "next"

import { SITE_URL } from "@/lib/constants"

export default function robots(): MetadataRoute.Robots {
let hostname = ""
try {
hostname = new URL(SITE_URL).hostname
} catch (error) {
console.error("Error getting hostname", error)
}

const isProduction = hostname === "ethereum.org"

if (!isProduction) {
return {
rules: [{ userAgent: "*", disallow: "/" }],
sitemap: [],
host: SITE_URL,
}
}

return {
rules: [{ userAgent: "*", allow: "/" }],
sitemap: [`${SITE_URL}/sitemap.xml`],
host: SITE_URL,
}
}
3 changes: 1 addition & 2 deletions next-sitemap.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,7 @@ const defaultLocale = "en"

/** @type {import('next-sitemap').IConfig} */
module.exports = {
siteUrl: process.env.SITE_URL || "https://ethereum.org",
generateRobotsTxt: true,
siteUrl: process.env.NEXT_PUBLIC_SITE_URL || "https://ethereum.org",
transform: async (_, path) => {
const rootPath = path.split("/")[1]
if (path.endsWith("/404")) return null
Expand Down
4 changes: 1 addition & 3 deletions src/lib/ab-testing/server.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,8 @@
import { SITE_URL } from "@/lib/constants"

import type { ABTestAssignment, ABTestConfig } from "./types"

const getABTestConfigs = async (): Promise<Record<string, ABTestConfig>> => {
try {
const response = await fetch(`${SITE_URL}/api/ab-config`, {
const response = await fetch("https://ethereum.org/api/ab-config", {
next: { revalidate: 3600 },
})

Expand Down