|
1 | | -This is a [Next.js](https://nextjs.org) project bootstrapped with [`create-next-app`](https://nextjs.org/docs/app/api-reference/cli/create-next-app). |
| 1 | +# Xinference Frontend |
2 | 2 |
|
3 | | -## Getting Started |
| 3 | +This is the Xinference Web UI, a Next.js app. In production it is built as a |
| 4 | +**static export**, bundled into the `xinference` Python package, and served by |
| 5 | +the Xinference backend itself — a single process, no Node.js runtime needed. |
4 | 6 |
|
5 | | -First, run the development server: |
| 7 | +## Local Development |
| 8 | + |
| 9 | +Start the backend first: |
6 | 10 |
|
7 | 11 | ```bash |
8 | | -npm run dev |
9 | | -# or |
10 | | -yarn dev |
11 | | -# or |
12 | | -pnpm dev |
13 | | -# or |
14 | | -bun dev |
| 12 | +xinference-local --host 127.0.0.1 --port 9997 |
15 | 13 | ``` |
16 | 14 |
|
17 | | -Open [http://localhost:3000](http://localhost:3000) with your browser to see the result. |
18 | | - |
19 | | -You can start editing the page by modifying `app/page.tsx`. The page auto-updates as you edit the file. |
| 15 | +Then start the frontend dev server: |
20 | 16 |
|
21 | | -This project uses [`next/font`](https://nextjs.org/docs/app/building-your-application/optimizing/fonts) to automatically optimize and load [Geist](https://vercel.com/font), a new font family for Vercel. |
| 17 | +```bash |
| 18 | +cd frontend |
| 19 | +npm ci |
| 20 | +npm run dev |
| 21 | +``` |
22 | 22 |
|
23 | | -## Learn More |
| 23 | +Open http://127.0.0.1:3999. |
24 | 24 |
|
25 | | -To learn more about Next.js, take a look at the following resources: |
| 25 | +In dev mode, the frontend proxies API requests to `http://127.0.0.1:9997`. To |
| 26 | +use a different backend endpoint: |
26 | 27 |
|
27 | | -- [Next.js Documentation](https://nextjs.org/docs) - learn about Next.js features and API. |
28 | | -- [Learn Next.js](https://nextjs.org/learn) - an interactive Next.js tutorial. |
| 28 | +```bash |
| 29 | +XINFERENCE_API_URL=http://127.0.0.1:6735 npm run dev |
| 30 | +``` |
29 | 31 |
|
30 | | -You can check out [the Next.js GitHub repository](https://github.com/vercel/next.js) - your feedback and contributions are welcome! |
| 32 | +For direct browser requests to a non-default backend, use |
| 33 | +`NEXT_PUBLIC_API_URL` instead. |
31 | 34 |
|
32 | | -## Deploy on Vercel |
| 35 | +## Build |
33 | 36 |
|
34 | | -The easiest way to deploy your Next.js app is to use the [Vercel Platform](https://vercel.com/new?utm_medium=default-template&filter=next.js&utm_source=create-next-app&utm_campaign=create-next-app-readme) from the creators of Next.js. |
| 37 | +```bash |
| 38 | +npm run build |
| 39 | +``` |
35 | 40 |
|
36 | | -Check out our [Next.js deployment documentation](https://nextjs.org/docs/app/building-your-application/deploying) for more details. |
| 41 | +This produces the static export in `out/` and stages it at |
| 42 | +`xinference/ui/web/dist` (postbuild hook), where the backend serves it. After |
| 43 | +building, `http://<backend-host>:9997/` serves the UI directly. |
| 44 | + |
| 45 | +Notes on the static export: |
| 46 | + |
| 47 | +- Dynamic routes (`launch-model/[modelType]`, `running-model/[modelUid]`, ...) |
| 48 | + are emitted as `__shell__` placeholder pages; the backend maps any real URL |
| 49 | + to the matching shell and the client reads the actual params from the URL |
| 50 | + (see `src/lib/route-params.ts` and `xinference/api/frontend_static.py`). |
| 51 | +- `next.config.ts` only enables rewrites (the dev API proxy) outside export |
| 52 | + mode; in production the UI is same-origin with the API, so no proxy is |
| 53 | + needed. |
| 54 | +- To build a self-contained Node server instead (no static export), use |
| 55 | + `NEXT_OUTPUT=standalone npm run build`. |
0 commit comments