feat: support setting app api use env

This commit is contained in:
Joel
2023-09-07 17:34:10 +08:00
parent 8f3dcd5462
commit 3838537a42
3 changed files with 22 additions and 12 deletions

6
.env.example Normal file
View File

@ -0,0 +1,6 @@
# APP ID
NEXT_PUBLIC_APP_ID=
# APP API key
NEXT_PUBLIC_APP_KEY=
# API url prefix
NEXT_PUBLIC_API_URL=

View File

@ -2,18 +2,22 @@
This is a [Next.js](https://nextjs.org/) project bootstrapped with [`create-next-app`](https://github.com/vercel/next.js/tree/canary/packages/create-next-app).
## Config App
Config app in `config/index.ts`.Please config:
- APP_ID
- API_KEY
Create a file named `.env.local` in the current directory and copy the contents from `.env.example`. Setting the following content:
```
# APP ID
NEXT_PUBLIC_APP_ID=
# APP API key
NEXT_PUBLIC_APP_KEY=
```
More config:
Config more in `config/index.ts` file:
```js
export const APP_INFO: AppInfo = {
"title": 'Chat APP',
"description": '',
"copyright": '',
"privacy_policy": '',
"default_language": 'zh-Hans'
title: 'Chat APP',
description: '',
copyright: '',
privacy_policy: '',
default_language: 'zh-Hans'
}
export const isShowPrompt = true

View File

@ -1,7 +1,7 @@
import type { AppInfo } from '@/types/app'
export const APP_ID = `${process.env.APP_ID}`
export const API_KEY = `${process.env.API_KEY}`
export const API_URL = `${process.env.API_URL}`
export const APP_ID = `${process.env.NEXT_PUBLIC_APP_ID}`
export const API_KEY = `${process.env.NEXT_PUBLIC_APP_KEY}`
export const API_URL = `${process.env.NEXT_PUBLIC_API_URL}`
export const APP_INFO: AppInfo = {
title: 'Chat APP',
description: '',