Skip to content

Latest commit

 

History

History
126 lines (101 loc) · 2.46 KB

File metadata and controls

126 lines (101 loc) · 2.46 KB

Astro Integration

Add AIEP Mirror to any Astro site in 5 minutes.

Install

pip install aiep-mirror

One-time setup

# Run in your Astro project root
aiep-mirror init

Edit the generated .aiep-mirror.json:

{
  "site_base": "https://yourdomain.com",
  "in_dir": "./dist",
  "out_dir": ".",
  "visibility_default": "PRIVATE",
  "public_prefixes": ["/blog", "/docs"],
  "private_prefixes": ["/admin", "/dashboard"]
}

Add to build pipeline

Add a postbuild script to package.json:

{
  "scripts": {
    "build": "astro build",
    "postbuild": "aiep-mirror build",
    "aiep:verify": "aiep-mirror verify",
    "aiep:status": "aiep-mirror status"
  }
}

Now npm run build automatically generates .well-known/aiep/ after the Astro build.

Verify before deploy

npm run aiep:verify

Astro config note

Astro outputs to ./dist by default — this matches the .aiep-mirror.json template.

If you use a custom outDir in astro.config.mjs, update in_dir in .aiep-mirror.json:

// astro.config.mjs
export default defineConfig({
  outDir: './build',   // ← update "in_dir" in .aiep-mirror.json to "./build"
})

Vercel / Netlify deploy

The .well-known/ directory must be served with correct headers. Add to your public/_headers (Netlify) or vercel.json:

Netlify (public/_headers):

/.well-known/aiep-manifest.json
  Content-Type: application/json
  Access-Control-Allow-Origin: *

/.well-known/aiep-index.json
  Content-Type: application/json
  Access-Control-Allow-Origin: *

/.well-known/aiep/*
  Content-Type: application/json
  Access-Control-Allow-Origin: *

Vercel (vercel.json):

{
  "headers": [
    {
      "source": "/.well-known/aiep/(.*)",
      "headers": [
        { "key": "Content-Type", "value": "application/json" },
        { "key": "Access-Control-Allow-Origin", "value": "*" }
      ]
    }
  ]
}

Full project example

my-astro-site/
  astro.config.mjs
  package.json
  .aiep-mirror.json          ← created by aiep-mirror init
  public/
    _headers                 ← CORS headers for .well-known/
  src/
    pages/
      index.astro
      blog/
        post-1.astro
  dist/                      ← npm run build output (Astro)
    index.html
    blog/
      post-1/index.html
  .well-known/               ← aiep-mirror build output
    aiep-manifest.json
    aiep-index.json
    aiep/
      pages/
      proofs/
      mirror_policy.json