mirror of
https://github.com/hanzoai/ads.git
synced 2026-09-30 20:39:45 +00:00
The ad plane at api.hanzo.ai/v1/ad had no screen of its own. This adds one beside the Go module, built the same way as Hanzo Social: campaigns with their totals, a campaign to launch, pause, edit or delete, ad accounts connected through /v1/integration, and spend against budget. It shows only what the API returns, so there is no targeting, creative or delivery data to draw. Co-authored-by: Hanzo Dev <[email protected]>
44 lines
1.4 KiB
TypeScript
44 lines
1.4 KiB
TypeScript
import { hanzo } from '@hanzo/vite'
|
|
import react from '@vitejs/plugin-react'
|
|
|
|
// api.hanzo.ai refuses a credentialed request from a localhost port, so dev and
|
|
// preview serve /v1 from their own origin and forward it.
|
|
const proxy = { '/v1': { target: 'https://api.hanzo.ai', changeOrigin: true } }
|
|
|
|
// Pinned: the port is part of the redirect URI registered with hanzo.id.
|
|
const PORT = 3310
|
|
|
|
// Every unknown address must reach the SPA; static hosts serve 404.html for it.
|
|
const spaFallback = {
|
|
name: 'spa-fallback',
|
|
async writeBundle(options: { dir?: string }) {
|
|
const { copyFile } = await import('node:fs/promises')
|
|
const { join } = await import('node:path')
|
|
const dir = options.dir ?? 'dist'
|
|
await copyFile(join(dir, 'index.html'), join(dir, '404.html'))
|
|
},
|
|
}
|
|
|
|
const config = hanzo(
|
|
{
|
|
plugins: [react(), spaFallback],
|
|
server: { port: PORT, allowedHosts: true, proxy },
|
|
preview: { port: PORT, allowedHosts: true, proxy },
|
|
},
|
|
{
|
|
root: import.meta.dirname,
|
|
// One copy of the theme context, or components throw "Missing theme."
|
|
dedupe: ['@hanzogui/core', '@hanzogui/web', '@hanzogui/portal', '@hanzogui/toast'],
|
|
},
|
|
)
|
|
|
|
// The dependency optimizer resolves separately; give it the same web-first extensions.
|
|
export default {
|
|
...config,
|
|
optimizeDeps: {
|
|
rollupOptions: {
|
|
resolve: { extensions: (config.resolve as { extensions: string[] }).extensions },
|
|
},
|
|
},
|
|
}
|