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

[Bug] 在 Vercel 使用 apiRouter 时,POST 请求会报 405 错误 #12325

Open
BarryBooder opened this issue Apr 23, 2024 · 2 comments
Open

Comments

@BarryBooder
Copy link

在 Vercel 使用 apiRouter 时,POST 请求会报 405 错误

我在 使用 umi 的apiRoute,按照 umi blog 的方式实现了对应的功能,包括用户登陆、查询用户信息等。使用的是 POST 请求,MySQL 数据库,在本地调试运行良好,当部署到 Vercel 后,报 405 错误。

尝试地址

obde
image
用户名和密码随便填

配置信息

import { defineConfig } from '@umijs/max';
import { join } from 'path';
import { routes } from './routes.config';

export default defineConfig({
  antd: {},
  access: {},
  model: {},
  initialState: {},
  request: {},
  alias: {
    '@': join(__dirname, 'src'),
  },
  apiRoute: {
    platform: 'vercel',
  },
  layout: {
    title: 'OB-DE-Tools',
  },
  routes,
  npmClient: 'yarn',
  tailwindcss: {},
});

版本信息

  • Umi Version:"@umijs/max": "^4.1.8",
  • Node Version:20.x
@fz6m
Copy link
Member

fz6m commented Apr 24, 2024

你发现了一个隐藏的功能,umi 4 以前做的这个兼容 vercel api router 的功能,太老了,而且几乎 0 人知道 0 人使用,加上 vercel 现在 api 的约定可能也发生了一些变化,所以到现在为止它不可用了也是正常的。

现在如果要用 vercel api ,最好自己根据 vercel api 的文档去编写和部署;不要用 umi 内置这个功能了,因为几乎没人用,也比不过 nextjs ,目测它的意义不大了。

如果有兴趣希望修订这部分让它重新可用,欢迎 PR 修复,代码路径在 packages/preset-umi/src/features/apiRoute/*

@dengfuping
Copy link
Contributor

绕过方案: 将 API 路由的构建产物一并提交到 Git。Ref: umijs/umi-blog-example#11

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

No branches or pull requests

3 participants