extremely claude-assisted go game based on atproto! working on cleaning up and giving a more unique design, still has a bit of a slop vibe to it.
at feature/study-tab 190 lines 3.6 kB view raw view rendered
1# Local Development with OAuth 2 3AT Protocol OAuth requires HTTPS URLs for security. For local development, you have two options: 4 5## Option 1: Use ngrok (Recommended) 6 7### 1. Install ngrok 8 9```bash 10# Using Homebrew (macOS) 11brew install ngrok 12 13# Or download from https://ngrok.com/download 14``` 15 16### 2. Start your dev server 17 18```bash 19npm run dev 20``` 21 22### 3. In a new terminal, start ngrok 23 24```bash 25ngrok http 5173 26``` 27 28You'll see output like: 29``` 30Forwarding https://abc123.ngrok-free.app -> http://localhost:5173 31``` 32 33### 4. Update your .env file 34 35Copy the HTTPS URL from ngrok and update `.env`: 36 37```bash 38PUBLIC_BASE_URL=https://abc123.ngrok-free.app 39``` 40 41### 5. Restart your dev server 42 43Stop and restart the dev server to pick up the new URL: 44 45```bash 46# Ctrl+C to stop, then: 47npm run dev 48``` 49 50### 6. Access your app via the ngrok URL 51 52Open `https://abc123.ngrok-free.app` in your browser and try logging in! 53 54**Note:** The ngrok URL changes each time you restart it (unless you have a paid account). You'll need to update `.env` each time. 55 56--- 57 58## Option 2: Local HTTPS with mkcert 59 60This creates a permanent local HTTPS setup. 61 62### 1. Install mkcert 63 64```bash 65# macOS 66brew install mkcert 67 68# Then install the local CA 69mkcert -install 70``` 71 72### 2. Generate certificates 73 74```bash 75cd /Users/dan/Documents/Coding/atprotogo 76mkdir -p .cert 77mkcert -key-file .cert/key.pem -cert-file .cert/cert.pem localhost 78``` 79 80### 3. Update vite.config.ts 81 82```typescript 83import { sveltekit } from '@sveltejs/kit/vite'; 84import { defineConfig } from 'vite'; 85import fs from 'fs'; 86 87export default defineConfig({ 88 plugins: [sveltekit()], 89 server: { 90 port: 5173, 91 https: { 92 key: fs.readFileSync('.cert/key.pem'), 93 cert: fs.readFileSync('.cert/cert.pem'), 94 }, 95 }, 96}); 97``` 98 99### 4. Update .env 100 101```bash 102PUBLIC_BASE_URL=https://localhost:5173 103``` 104 105### 5. Restart dev server 106 107```bash 108npm run dev 109``` 110 111Access at `https://localhost:5173` 112 113**Note:** AT Protocol servers may still reject `localhost` URLs. In that case, use ngrok. 114 115--- 116 117## Option 3: Use a Custom Domain (Advanced) 118 119If you have a domain, you can: 1201. Set up a subdomain (e.g., `dev.yourdomain.com`) 1212. Point it to your local machine via /etc/hosts 1223. Use Caddy or nginx for HTTPS reverse proxy 1234. Update PUBLIC_BASE_URL to your subdomain 124 125--- 126 127## Quick Start Script (ngrok) 128 129Create a helper script for easy development: 130 131**scripts/dev-with-ngrok.sh:** 132```bash 133#!/bin/bash 134 135# Start dev server in background 136npm run dev & 137DEV_PID=$! 138 139# Wait for server to start 140sleep 3 141 142# Start ngrok 143echo "Starting ngrok tunnel..." 144ngrok http 5173 145 146# Cleanup on exit 147trap "kill $DEV_PID" EXIT 148``` 149 150Make it executable: 151```bash 152chmod +x scripts/dev-with-ngrok.sh 153``` 154 155Then run: 156```bash 157./scripts/dev-with-ngrok.sh 158``` 159 160**Remember to update PUBLIC_BASE_URL in .env with the ngrok URL before testing!** 161 162--- 163 164## Testing Without OAuth (Alternative) 165 166If you want to skip OAuth for now and test the game functionality: 167 1681. Comment out the OAuth check in protected endpoints 1692. Manually set a test session in your browser console 1703. Use the API directly with a test DID 171 172**Not recommended for production**, but useful for testing game logic. 173 174--- 175 176## Production Deployment 177 178For production: 179- Deploy to a hosting service (Vercel, Netlify, Railway, etc.) 180- Use your production domain in PUBLIC_BASE_URL 181- Ensure HTTPS is enabled (automatic on most platforms) 182- Regenerate PRIVATE_KEY_JWK for production 183 184Example production .env: 185```bash 186PUBLIC_BASE_URL=https://atprotogo.yourdomain.com 187PRIVATE_KEY_JWK={"kty":"EC"...} 188DATABASE_PATH=/var/data/app.db 189SESSION_SECRET=long-random-production-secret 190```