Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

本地运行插件报错 #1008

Closed
scortLi opened this issue Jan 11, 2024 · 22 comments
Closed

本地运行插件报错 #1008

scortLi opened this issue Jan 11, 2024 · 22 comments

Comments

@scortLi
Copy link

scortLi commented Jan 11, 2024

💻 系统环境

Windows

📦 部署环境

Official Preview

🌐 浏览器

Chrome

🐛 问题描述

请求 URL:
http://xxxxxxx:3400/api/gateway
请求方法:
OPTIONS
状态代码:
500 Internal Server Error
如何解决

🚦 期望结果

docker运行lobe- chat 镜像 本地运行lobe-chat-plugin-template插件,然后lobe-chat 添加插件跨域报错
Uploading 企业微信截图_17049387921085.png…

📷 复现步骤

No response

📝 补充信息

No response

@scortLi scortLi added the 🐛 Bug Something isn't working | 缺陷 label Jan 11, 2024
@lobehubbot
Copy link
Member

👀 @lihui123456

Thank you for raising an issue. We will investigate into the matter and get back to you as soon as possible.
Please make sure you have given us as much context as possible.
非常感谢您提交 issue。我们会尽快调查此事,并尽快回复您。 请确保您已经提供了尽可能多的背景信息。

@scortLi
Copy link
Author

scortLi commented Jan 11, 2024

  • error Error [TypeError]: req.headers.get is not a function
    at originHeadersFromReq (F:\openAI\lobe\chat-plugin-template\node_modules@lobehub\chat-plugins-gateway\dist\cors.js:52:33)
    at cors (F:\openAI\lobe\chat-plugin-template\node_modules@lobehub\chat-plugins-gateway\dist\cors.js:74:31)
    at F:\openAI\lobe\chat-plugin-template\node_modules@lobehub\chat-plugins-gateway\dist\edge.js:62:49
    at process.processTicksAndRejections (node:internal/process/task_queues:95:5) {
    digest: undefined
    } 报错信息

@arvinxx
Copy link
Contributor

arvinxx commented Jan 11, 2024

有截图吗?

@lobehubbot
Copy link
Member

Bot detected the issue body's language is not English, translate it automatically. 👯👭🏻🧑‍🤝‍🧑👫🧑🏿‍🤝‍🧑🏻👩🏾‍🤝‍👨🏿👬🏿


Are there any screenshots?

@scortLi
Copy link
Author

scortLi commented Jan 11, 2024

@arvinxx
image
企业微信截图_17049391731105

@scortLi
Copy link
Author

scortLi commented Jan 11, 2024

@lobehubbot 截图如上图所示

@lobehubbot
Copy link
Member

Bot detected the issue body's language is not English, translate it automatically. 👯👭🏻🧑‍🤝‍🧑👫🧑🏿‍🤝‍🧑🏻👩🏾‍🤝‍👨🏿👬🏿


@lobehubbot screenshot is shown above

@arvinxx
Copy link
Contributor

arvinxx commented Jan 11, 2024

本地运行lobe-chat-plugin-template插件的花,请求不应该会打到这个域名去的,你是不是添加的插件 manifest 不对?本地开发应该 添加 manifest-dev.json ?

@scortLi
Copy link
Author

scortLi commented Jan 11, 2024

@arvinxx
image
企业微信截图_17049394763633
这是我ti添加插件和mainfest,麻烦帮忙看看吧,困扰好久了,非常感谢

@arvinxx
Copy link
Contributor

arvinxx commented Jan 11, 2024

image 这一块 revert 一下吧,不需要改哈

@arvinxx arvinxx removed the 🐛 Bug Something isn't working | 缺陷 label Jan 11, 2024
@scortLi
Copy link
Author

scortLi commented Jan 11, 2024

@arvinxx 现在改成这样了
企业微信截图_17049409512474
image
image
全改成localhost了不知道为啥还是访问的是ip
,大神有空帮忙看看哈

@lobehubbot
Copy link
Member

Bot detected the issue body's language is not English, translate it automatically. 👯👭🏻🧑‍🤝‍🧑👫🧑🏿‍🤝‍🧑🏻👩🏾‍🤝‍👨🏿👬🏿


@arvinxx Now it’s changed to this
Enterprise WeChat screenshot_17049409512474
image
image
I changed everything to localhost, but I don’t know why I still access the IP address.
, God, please help me when you have time.

@scortLi
Copy link
Author

scortLi commented Jan 11, 2024

@arvinxx 现在都改成localhost了 还是报错
image
不知道什么原因

@arvinxx
Copy link
Contributor

arvinxx commented Jan 11, 2024

@lihui123456 排查下来是我们的模板的问题,抱歉耽搁你时间了🙇‍♂️

请把 gateway.ts 的代码替换为

import { createGatewayOnEdgeRuntime } from '@lobehub/chat-plugins-gateway';

export const config = {
  runtime: 'edge',
};

export default async (req: Request) => {
  if (process.env.NODE_ENV === 'development') {
    return createGatewayOnEdgeRuntime()(req);
  }

  return new Response('gateway');
};

应该是之前更新的时候忘记修改这里的代码了。我去修正一下模板的

@scortLi
Copy link
Author

scortLi commented Jan 11, 2024

@arvinxx 我这边可以了,谢谢您

@lobehubbot
Copy link
Member

Bot detected the issue body's language is not English, translate it automatically. 👯👭🏻🧑‍🤝‍🧑👫🧑🏿‍🤝‍🧑🏻👩🏾‍🤝‍👨🏿👬🏿


@arvinxx I can do it, thank you

@arvinxx
Copy link
Contributor

arvinxx commented Jan 11, 2024

已修复: lobehub/chat-plugin-template#24

@arvinxx arvinxx closed this as completed Jan 11, 2024
@lobehubbot
Copy link
Member

✅ @lihui123456

This issue is closed, If you have any questions, you can comment and reply.
此问题已经关闭。如果您有任何问题,可以留言并回复。

@arvinxx
Copy link
Contributor

arvinxx commented Jan 11, 2024

@lihui123456 更新一下,上述代码在 next build 时会报错。要改成动态导入的方式:

export const config = {
  runtime: 'edge',
};

export default async (req: Request) => {
  if (process.env.NODE_ENV === 'development') {
    const { createGatewayOnEdgeRuntime } = await import('@lobehub/chat-plugins-gateway');

    return createGatewayOnEdgeRuntime()(req);
  }

  return new Response('gateway');
};

@lobehubbot
Copy link
Member

Bot detected the issue body's language is not English, translate it automatically. 👯👭🏻🧑‍🤝‍🧑👫🧑🏿‍🤝‍🧑🏻👩🏾‍🤝‍👨🏿👬🏿


@lihui123456 Update, the above code will report an error during next build. To change to dynamic import:

export const config = {
  runtime: 'edge',
};

export default async (req: Request) => {
  if (process.env.NODE_ENV === 'development') {
    const { createGatewayOnEdgeRuntime } = await import('@lobehub/chat-plugins-gateway');

    return createGatewayOnEdgeRuntime()(req);
  }

  return new Response('gateway');
};

@scortLi
Copy link
Author

scortLi commented Jan 11, 2024

@arvinxx 好的,非常感谢

@lobehubbot
Copy link
Member

Bot detected the issue body's language is not English, translate it automatically. 👯👭🏻🧑‍🤝‍🧑👫🧑🏿‍🤝‍🧑🏻👩🏾‍🤝‍👨🏿👬🏿


@arvinxx ok thank you very much

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Archived in project
Development

No branches or pull requests

3 participants