Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

posts/mastodon-on-your-own-domain-without-hosting-a-server-netlify-edition/ #56

Open
utterances-bot opened this issue Nov 16, 2022 · 2 comments

Comments

@utterances-bot
Copy link

Mastodon on your own domain without hosting a server, Netlify edition | Harsh Shandilya

A quick and easy way of creating a Fediverse identity on your own domain without an ActivityPub server

https://msfjarvis.dev/posts/mastodon-on-your-own-domain-without-hosting-a-server-netlify-edition/

Copy link

Thanks for writing this up :) I copied your approach, but made a change to retrieve the /.well-known/webfinger data from my Mastodon instance directly. Inside the Edge Function I fetch it, then return a modified version of that response. That way, any changes that Hachyderm makes will be reflected in my endpoint, and the headers like content-type: application/jrd+json; charset=utf-8 are retained:

import { Status } from 'https://deno.land/std@0.136.0/http/http_status.ts';

export default async (request, context) => {
  const url = new URL(request.url);
  const resourceParam = url.searchParams.get('resource');

  if (resourceParam === null) {
    return context.json(
      {
        error: "No 'resource' query parameter was provided",
      },
      {
        status: Status.BadRequest,
      }
    );
  }

  if (resourceParam !== 'acct:phil@wolstenhol.me') {
    return context.json(
      {
        error: 'An invalid identity was requested',
      },
      {
        status: Status.BadRequest,
      }
    );
  }

  const webfingerResponse = await fetch('https://hachyderm.io/.well-known/webfinger?resource=acct:philw_@hachyderm.io');
  const json = await webfingerResponse.json();

  json.links.push({
    rel: 'http://webfinger.net/rel/profile-page',
    type: 'text/html',
    href: 'https://wolstenhol.me',
  });

  return new Response(JSON.stringify(json), webfingerResponse);
};

@msfjarvis
Copy link
Owner

That's quite clever! Thanks for sharing it :D

Repository owner deleted a comment from xgecemx2 Oct 6, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants