Closed JeongYunLee closed 1 year ago
Have you run "yarn install" before running "yarn dev"?
On Tue, Apr 11, 2023 at 4:38 PM JeongYun Lee @.***> wrote:
I think the update version have some problems. (in server/middleware/apiProxy.ts)
I have some errors when I run yarn dev and my code is this.
current version
import { createProxyMiddleware } from 'http-proxy-middleware' export default defineEventHandler(async (event) => { await new Promise((resolve, reject) => { createProxyMiddleware({ target: process.env.SERVER_DOMAIN, pathFilter: '/api', })(event.node.req, event.node.res, (err) => { if (err) reject(err) else resolve(true) }) }) })
but when I run with this code everything is good.
previous version
const PayloadMethods = new Set(["PATCH", "POST", "PUT", "DELETE"]); export default defineEventHandler(async (event) => { // @ts-ignore if (event.node.req.url.startsWith('/api/')) { // TODO: fix fetch failed const target = (process.env.SERVER_DOMAIN || 'http://localhost:8000') + event.node.req.url // Method const method = getMethod(event) // Body let body; if (PayloadMethods.has(method)) { body = await readRawBody(event).catch(() => undefined); } // Headers const headers = getProxyRequestHeaders(event); if (method === 'DELETE') { delete headers['content-length'] } return sendProxy(event, target, { sendStream: event.node.req.url === '/api/conversation/', fetchOptions: { headers, method, body, }, }); } })
— Reply to this email directly, view it on GitHub https://github.com/WongSaang/chatgpt-ui/issues/139, or unsubscribe https://github.com/notifications/unsubscribe-auth/ALAX6FFWSPJ5SFHBEIBU6DTXAUJ63ANCNFSM6AAAAAAWZ6PRGI . You are receiving this because you are subscribed to this thread.Message ID: @.***>
yes i did
What's the error content?
This is my error.
500
[HPM] Missing "target" option. Example: {target: "http://www.example.org"}
at verifyConfig (./node_modules/http-proxy-middleware/dist/configuration.js:7:15)
at new HttpProxyMiddleware (./node_modules/http-proxy-middleware/dist/http-proxy-middleware.js:124:42)
at createProxyMiddleware (./node_modules/http-proxy-middleware/dist/index.js:20:28)
at ./.nuxt/dev/index.mjs:541:5
at new Promise ()
at Object.handler (./.nuxt/dev/index.mjs:540:9)
at Object.handler (./node_modules/h3/dist/index.mjs:1247:31)
at processTicksAndRejections (node:internal/process/task_queues:96:5)
at async toNodeHandle (./node_modules/h3/dist/index.mjs:1322:7)
at async Object.ufetch [as localFetch] (./node_modules/unenv/runtime/fetch/index.mjs:9:17)
I run django server(localhost:8000) but still have the same error
(my yarn version is v1.22.19
and node version is v16.20.0
)
Please add the environment variable SERVER_DOMAIN=http://backend
to the
.env file.
On Wed, Apr 12, 2023 at 9:43 AM JeongYun Lee @.***> wrote:
This is my error.
500 [HPM] Missing "target" option. Example: {target: "http://www.example.org"}
at verifyConfig (./node_modules/http-proxy-middleware/dist/configuration.js:7:15) at new HttpProxyMiddleware (./node_modules/http-proxy-middleware/dist/http-proxy-middleware.js:124:42) at createProxyMiddleware (./node_modules/http-proxy-middleware/dist/index.js:20:28) at ./.nuxt/dev/index.mjs:541:5 at new Promise () at Object.handler (./.nuxt/dev/index.mjs:540:9) at Object.handler (./node_modules/h3/dist/index.mjs:1247:31) at processTicksAndRejections (node:internal/process/task_queues:96:5) at async toNodeHandle (./node_modules/h3/dist/index.mjs:1322:7) at async Object.ufetch [as localFetch] (./node_modules/unenv/runtime/fetch/index.mjs:9:17)
I run django server(localhost:8000) but still have the same error (my yarn version is v1.22.19 and node version is v16.20.0)
— Reply to this email directly, view it on GitHub https://github.com/WongSaang/chatgpt-ui/issues/139#issuecomment-1504405599, or unsubscribe https://github.com/notifications/unsubscribe-auth/ALAX6FFCGABTJXS7P7GK3C3XAYCD7ANCNFSM6AAAAAAWZ6PRGI . You are receiving this because you commented.Message ID: @.***>
I understand what you mean and it runs well! Thanks for your help 😃
请问.env 文件在哪里呢
you can't see .env file on local. you need to use text editor(ex vscode) or if you can't find either, you have to make the file
I can not find the template.env ,so I create a new .env file . the content is below: SERVER_DOMAIN = "http://127.0.0.1:8000/" anything else?
that's all 👍
you can't see .env file on local. you need to use text editor(ex vscode) or if you can't find either, you have to make the file
Where should the.env file be placed? The root directory of the project?
yes
yes
Have you attempted to start the project with the command node .output/server/index.mjs
after yarn build
to deploy the project? It seems the .env file cannot be read.
I think the update version have some problems. (in server/middleware/apiProxy.ts)
I have some errors when I run
yarn dev
and my code is this.but when I run with this code everything is good.