{"id":19030677,"url":"https://github.com/hackclub/scrapbook-domains","last_synced_at":"2025-04-23T16:06:32.950Z","repository":{"id":42477325,"uuid":"272264893","full_name":"hackclub/scrapbook-domains","owner":"hackclub","description":"Custom domain support for https://scrapbook.hackclub.com/","archived":false,"fork":false,"pushed_at":"2023-10-24T23:06:25.000Z","size":104,"stargazers_count":15,"open_issues_count":1,"forks_count":2,"subscribers_count":4,"default_branch":"main","last_synced_at":"2025-04-23T16:06:28.650Z","etag":null,"topics":["hackclub","serverless","summer-of-making"],"latest_commit_sha":null,"homepage":"https://scrapbook.hackclub.com/","language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/hackclub.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2020-06-14T18:57:15.000Z","updated_at":"2024-07-30T01:53:26.000Z","dependencies_parsed_at":"2024-11-08T21:19:26.344Z","dependency_job_id":"b93e0509-7ec8-420a-9946-62dd5ce3b689","html_url":"https://github.com/hackclub/scrapbook-domains","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/hackclub%2Fscrapbook-domains","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/hackclub%2Fscrapbook-domains/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/hackclub%2Fscrapbook-domains/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/hackclub%2Fscrapbook-domains/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/hackclub","download_url":"https://codeload.github.com/hackclub/scrapbook-domains/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":250468273,"owners_count":21435452,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["hackclub","serverless","summer-of-making"],"created_at":"2024-11-08T21:19:05.810Z","updated_at":"2025-04-23T16:06:32.933Z","avatar_url":"https://github.com/hackclub.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# 🚨 DEPRECATED: [Scrapbook](https://scrapbook.hackclub.com/) Domains\n\n\u003e This repo's functionality is now in [the main Scrapbook codebase](https://github.com/hackclub/scrapbook).\n\nThis repo/function handles the custom domain functionality for [Hack Club](https://hackclub.com/)’s [Scrapbook](https://scrapbook.hackclub.com/), which was built as part of the [2020 Summer of Making](https://summer.hackclub.com/).\n\nTo set up a custom domain, refer to the [Scrapbook’s About page](https://scrapbook.hackclub.com/).\n\n## Why does this exist?\n\nThe profile pages run in the [Next.js app](https://github.com/hackclub/scrapbook), where they’re [statically rendered](https://nextjs.org/docs/basic-features/data-fetching#getstaticprops-static-generation) for performance. We want people to point their own domains to the site, but you can’t CNAME to a specific path, so we need to serve the custom domain functionality at the root path. This would be doable with [`getServerSideProps`](https://nextjs.org/docs/basic-features/data-fetching#getserversideprops-server-side-rendering) in Next (checking the `host` header \u0026 serving the appropriate page), but it’d mean a performance hit \u0026 higher sever load for every hit to the website, which we want to avoid. This is a single [serverless function](https://vercel.com/docs/v2/serverless-functions/introduction) to serve custom domains.\n\n## How does this work?\n\nBehind the scenes, when you invoke the Slack slash command to add a custom domain, it hits an [API Route](https://nextjs.org/docs/api-routes/introduction) on the [website codebase](https://github.com/hackclub/scrapbook). That function:\n\n1. Sets the domain on your user record in Airtable\n2. Uses the [Vercel API](https://vercel.com/docs/api#getting-started/introduction) to [add a custom domain](https://vercel.com/docs/api#endpoints/projects/add-a-domain-to-a-project) to this project\n\nThis project is a single serverless function with a [rewrite](https://vercel.com/docs/configuration?query=rewrite#project/rewrites) at the root to it (`api/index.js`). When that site is accessed, we:\n\n1. Get the `host` header of your request\n2. Find the user by that domain in our Airtable database, accessed over [api2](https://github.com/hackclub/api2)\n3. Fetch the HTML of the profile page from the [live site](https://scrapbook.hackclub.com/)\n4. Serve that HTML directly\n\nThis means social cards, etc still work as expected, because while slower than accessing the main Scrapbook domain, the custom domain serves the profile as a regular HTML page, even though it doesn’t generate any of that HTML or JS in this project.\n\n---\n\nBy [@lachlanjc](https://lachlanjc.com) for Hack Club, 2020. MIT License.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fhackclub%2Fscrapbook-domains","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fhackclub%2Fscrapbook-domains","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fhackclub%2Fscrapbook-domains/lists"}