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
5 changes: 0 additions & 5 deletions .github/workflows/deploy-cf.yml
Original file line number Diff line number Diff line change
Expand Up @@ -25,11 +25,6 @@ jobs:
run: npm ci

- name: Build project (Next.js)
env:
NEXT_PUBLIC_SUPABASE_URL: ${{ secrets.NEXT_PUBLIC_SUPABASE_URL }}
NEXT_PUBLIC_SUPABASE_ANON_KEY: ${{ secrets.NEXT_PUBLIC_SUPABASE_ANON_KEY }}
SUPABASE_SERVICE_ROLE_KEY: ${{ secrets.SUPABASE_SERVICE_ROLE_KEY }}
NEXT_PUBLIC_APP_URL: ${{ github.ref == 'refs/heads/main' && 'https://cookie.neonevm.org' || 'https://develop.fortune-cookie-4bg.pages.dev' }}
run: npm run build

- name: Generate Cloudflare Pages artifacts (Next on Pages)
Expand Down
2 changes: 1 addition & 1 deletion DOMAIN_CHANGE_GUIDE.md
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ When you change the domain in `config.ts`, these will automatically use the new

## Current Configuration

- **Production Domain**: `https://fortune-cookie-umber.vercel.app`
- **Production Domain**: `https://cookie.neonevm.org`
- **Development Domain**: `http://localhost:3003`
- **Auto-detection**: Uses production domain when `NODE_ENV=production`

Expand Down
6 changes: 3 additions & 3 deletions deployment-setup.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ SUPABASE_SERVICE_ROLE_KEY=your_supabase_service_role_key

### Example for Vercel:
```bash
NEXT_PUBLIC_APP_URL=https://fortune-cookie-umber.vercel.app
NEXT_PUBLIC_APP_URL=https://cookie.neonevm.org
NEXT_PUBLIC_SUPABASE_URL=https://your-project.supabase.co
SUPABASE_SERVICE_ROLE_KEY=your_service_role_key
```
Expand All @@ -25,11 +25,11 @@ After deployment, you'll need to update existing fortune records to use the prod
```sql
-- Update all existing fortune records to use production domain
UPDATE public.fortunes
SET share_url = REPLACE(share_url, 'http://localhost:3002', 'https://fortune-cookie-umber.vercel.app')
SET share_url = REPLACE(share_url, 'http://localhost:3002', 'https://cookie.neonevm.org')
WHERE share_url LIKE '%localhost%';

UPDATE public.fortunes
SET share_url = REPLACE(share_url, 'http://localhost:3003', 'https://fortune-cookie-umber.vercel.app')
SET share_url = REPLACE(share_url, 'http://localhost:3003', 'https://cookie.neonevm.org')
WHERE share_url LIKE '%localhost%';
```

Expand Down
32 changes: 26 additions & 6 deletions migration-production-urls.sql
Original file line number Diff line number Diff line change
@@ -1,16 +1,36 @@
-- Migration script to update fortune URLs for production deployment
-- Run this after deploying to production with the correct domain
-- Migration script to update fortune URLs to new domain
-- Run this after deploying to production with the new domain

-- Replace localhost URLs with production domain
-- Check current URLs before migration
SELECT 'Before migration:' as status, share_url, count(*) as count
FROM public.fortunes
GROUP BY share_url;

-- Replace old Vercel domain with new custom domain
UPDATE public.fortunes
SET share_url = REPLACE(share_url, 'http://localhost:3002', 'https://fortune-cookie-umber.vercel.app')
WHERE share_url LIKE '%localhost%';
SET share_url = REPLACE(share_url, 'https://fortune-cookie-umber.vercel.app', 'https://cookie.neonevm.org')
WHERE share_url LIKE '%fortune-cookie-umber.vercel.app%';

-- Replace any remaining localhost URLs with new domain
UPDATE public.fortunes
SET share_url = REPLACE(share_url, 'http://localhost:3002', 'https://cookie.neonevm.org')
WHERE share_url LIKE '%localhost:3002%';

UPDATE public.fortunes
SET share_url = REPLACE(share_url, 'http://localhost:3003', 'https://fortune-cookie-umber.vercel.app')
SET share_url = REPLACE(share_url, 'http://localhost:3003', 'https://cookie.neonevm.org')
WHERE share_url LIKE '%localhost:3003%';

-- Replace any other localhost variations
UPDATE public.fortunes
SET share_url = REPLACE(share_url, 'http://localhost:3000', 'https://cookie.neonevm.org')
WHERE share_url LIKE '%localhost%';

-- Verify the update
SELECT 'After migration:' as status, share_url, count(*) as count
FROM public.fortunes
GROUP BY share_url;

-- Show recent records to verify
SELECT id, slug, handle, share_url, created_at
FROM public.fortunes
ORDER BY created_at DESC
Expand Down
Binary file removed public/assets/cookies/._Fortune Cookie 1.png
Binary file not shown.
Binary file removed public/assets/cookies/._Fortune Cookie 10.png
Binary file not shown.
Binary file removed public/assets/cookies/._Fortune Cookie 11.png
Binary file not shown.
Binary file removed public/assets/cookies/._Fortune Cookie 12.png
Binary file not shown.
Binary file removed public/assets/cookies/._Fortune Cookie 13.png
Binary file not shown.
Binary file removed public/assets/cookies/._Fortune Cookie 14.png
Binary file not shown.
Binary file removed public/assets/cookies/._Fortune Cookie 15.png
Binary file not shown.
Binary file removed public/assets/cookies/._Fortune Cookie 16.png
Binary file not shown.
Binary file removed public/assets/cookies/._Fortune Cookie 17.png
Binary file not shown.
Binary file removed public/assets/cookies/._Fortune Cookie 18.png
Binary file not shown.
Binary file removed public/assets/cookies/._Fortune Cookie 19.png
Binary file not shown.
Binary file removed public/assets/cookies/._Fortune Cookie 2.png
Binary file not shown.
Binary file removed public/assets/cookies/._Fortune Cookie 20.png
Binary file not shown.
Binary file removed public/assets/cookies/._Fortune Cookie 21.png
Binary file not shown.
Binary file removed public/assets/cookies/._Fortune Cookie 22.png
Binary file not shown.
Binary file removed public/assets/cookies/._Fortune Cookie 23.png
Binary file not shown.
Binary file removed public/assets/cookies/._Fortune Cookie 24.png
Binary file not shown.
Binary file removed public/assets/cookies/._Fortune Cookie 25.png
Binary file not shown.
Binary file removed public/assets/cookies/._Fortune Cookie 26.png
Binary file not shown.
Binary file removed public/assets/cookies/._Fortune Cookie 27.png
Binary file not shown.
Binary file removed public/assets/cookies/._Fortune Cookie 28.png
Binary file not shown.
Binary file removed public/assets/cookies/._Fortune Cookie 29.png
Binary file not shown.
Binary file removed public/assets/cookies/._Fortune Cookie 3.png
Binary file not shown.
Binary file removed public/assets/cookies/._Fortune Cookie 30.png
Binary file not shown.
Binary file removed public/assets/cookies/._Fortune Cookie 31.png
Binary file not shown.
Binary file removed public/assets/cookies/._Fortune Cookie 32.png
Diff not rendered.
Binary file removed public/assets/cookies/._Fortune Cookie 33.png
Diff not rendered.
Binary file removed public/assets/cookies/._Fortune Cookie 34.png
Diff not rendered.
Binary file removed public/assets/cookies/._Fortune Cookie 35.png
Diff not rendered.
Binary file removed public/assets/cookies/._Fortune Cookie 36.png
Diff not rendered.
Binary file removed public/assets/cookies/._Fortune Cookie 37.png
Diff not rendered.
Binary file removed public/assets/cookies/._Fortune Cookie 38.png
Diff not rendered.
Binary file removed public/assets/cookies/._Fortune Cookie 39.png
Diff not rendered.
Binary file removed public/assets/cookies/._Fortune Cookie 4.png
Diff not rendered.
Binary file removed public/assets/cookies/._Fortune Cookie 40.png
Diff not rendered.
Binary file removed public/assets/cookies/._Fortune Cookie 41.png
Diff not rendered.
Binary file removed public/assets/cookies/._Fortune Cookie 42.png
Diff not rendered.
Binary file removed public/assets/cookies/._Fortune Cookie 43.png
Diff not rendered.
Binary file removed public/assets/cookies/._Fortune Cookie 44.png
Diff not rendered.
Binary file removed public/assets/cookies/._Fortune Cookie 45.png
Diff not rendered.
Binary file removed public/assets/cookies/._Fortune Cookie 46.png
Diff not rendered.
Binary file removed public/assets/cookies/._Fortune Cookie 47.png
Diff not rendered.
Binary file removed public/assets/cookies/._Fortune Cookie 48.png
Diff not rendered.
Binary file removed public/assets/cookies/._Fortune Cookie 49.png
Diff not rendered.
Binary file removed public/assets/cookies/._Fortune Cookie 5.png
Diff not rendered.
Binary file removed public/assets/cookies/._Fortune Cookie 50.png
Diff not rendered.
Binary file removed public/assets/cookies/._Fortune Cookie 51.png
Diff not rendered.
Binary file removed public/assets/cookies/._Fortune Cookie 6.png
Diff not rendered.
Binary file removed public/assets/cookies/._Fortune Cookie 7.png
Diff not rendered.
Binary file removed public/assets/cookies/._Fortune Cookie 8.png
Diff not rendered.
Binary file removed public/assets/cookies/._Fortune Cookie 9.png
Diff not rendered.
9 changes: 7 additions & 2 deletions src/app/api/fortune/route.ts
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,11 @@ export async function POST(request: NextRequest) {
)
}

// Normalize local asset URL to avoid spaces breaking on some CDNs/hosts
const normalizedImageUrl = image.url.startsWith('/assets/cookies/')
? image.url.replace(/\s/g, '-')
: image.url

// Generate unique slug
const slug = nanoid(6)
const shareUrl = `${getAppUrl()}/f/${slug}`
Expand All @@ -62,7 +67,7 @@ export async function POST(request: NextRequest) {
slug,
handle: normalizedHandle,
image_id: image.id,
image_url: image.url,
image_url: normalizedImageUrl,
ip_hash: ip, // In production, hash this for privacy
user_agent: userAgent,
share_url: shareUrl,
Expand All @@ -80,7 +85,7 @@ export async function POST(request: NextRequest) {
shareUrl,
image: {
id: image.id,
url: image.url,
url: normalizedImageUrl,
},
})

Expand Down
11 changes: 6 additions & 5 deletions src/app/f/[slug]/SharePageClient.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -115,11 +115,12 @@ export default function SharePageClient({ fortune }: Props) {
}
}

const imageUrl = fortune.image_url.startsWith('http')
? fortune.image_url
const normalized = fortune.image_url.replace(/\s/g, '-')
const imageUrl = normalized.startsWith('http')
? normalized
: (typeof window !== 'undefined'
? new URL(fortune.image_url, window.location.origin).toString()
: fortune.image_url) // during SSR we won't render the <img> anyway
? new URL(normalized, window.location.origin).toString()
: normalized) // during SSR we won't render the <img> anyway

// Debug logging
console.log('Fortune data:', fortune)
Expand Down Expand Up @@ -208,7 +209,7 @@ export default function SharePageClient({ fortune }: Props) {
console.error('Image failed to load:', imageUrl)
console.error('Error details:', e)
// fallback on the SAME origin as the page, not 3002
e.currentTarget.src = new URL('/assets/cookies/Fortune Cookie 1.png', window.location.origin).toString()
e.currentTarget.src = new URL('/assets/cookies/Fortune-Cookie-1.png', window.location.origin).toString()
}}
onLoad={() => {
console.log('Image loaded successfully:', imageUrl)
Expand Down
8 changes: 5 additions & 3 deletions src/app/f/[slug]/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,11 @@ export async function generateMetadata({ params }: Props): Promise<Metadata> {
const handle = fortune.handle
// Use centralized configuration for domain
const base = getAppUrl()
const imageUrl = fortune.image_url.startsWith('http')
? fortune.image_url
: new URL(fortune.image_url, base).toString()
// Normalize spaces to hyphens to avoid 404s on some hosts/CDNs
const normalizedPath = fortune.image_url.replace(/\s/g, '-')
const imageUrl = normalizedPath.startsWith('http')
? normalizedPath
: new URL(normalizedPath, base).toString()

return {
title: `@${handle}'s ${app.name}`,
Expand Down
4 changes: 4 additions & 0 deletions src/app/icon.svg
7 changes: 5 additions & 2 deletions src/app/layout.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -62,8 +62,11 @@ const syne = localFont({
});

export const metadata: Metadata = {
title: "Fortune Cookie App",
description: "Get your mean crypto fortune",
title: "Mean Crypto Fortune Cookie",
description: "Get roasted by the crypto gods with your personalized fortune cookie",
icons: {
icon: '/icon.svg',
},
};

export default function RootLayout({
Expand Down
2 changes: 1 addition & 1 deletion src/app/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -206,7 +206,7 @@ export default function Home() {
console.error('Image failed to load:', fortune.image.url)
console.error('Error details:', e)
// fallback on the SAME origin as the page
e.currentTarget.src = new URL('/assets/cookies/Fortune Cookie 1.png', window.location.origin).toString()
e.currentTarget.src = new URL('/assets/cookies/Fortune-Cookie-1.png', window.location.origin).toString()
}}
onLoad={() => {
console.log('Image loaded successfully:', fortune.image.url)
Expand Down
Binary file added temp-neon-logo.png