Coder Social home page Coder Social logo

umijs / umi-blog-example Goto Github PK

View Code? Open in Web Editor NEW
35.0 4.0 32.0 455 KB

An example of blog website built with Umi.js and new API route feature in Umi 4.

Home Page: https://umijs.org/docs/tutorials/blog

TypeScript 97.55% Less 0.64% JavaScript 0.31% CSS 1.50%
api-routes blog react reactjs serverless serverless-functions umi umijs

umi-blog-example's Introduction

umi-blog-example

An example of blog website built with Umi.js and new API route feature in Umi 4. (WIP)

umi-blog-example's People

Contributors

yuaanlin avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar

umi-blog-example's Issues

示例博客首页无法加载?

部署在 Vercel 上的示例博客无法正常显示?
Serverless Function 无法正常运行。

image

我自己尝试的时候也是无法成功,不知道是什么原因呢

@/utils/jwt 包未找到

大佬好,我想请教下 @/utils/jwt这个是什么安装包,vscode显示找不到模块
我目前是用jwt生成的 token jwt.sign()

执行 npx prisma migrate dev --name init 报错

各位大佬。我在执行完 npx prisma migrate dev --name init之后,出现了报错。报错信息是:

Error: P3014

Prisma Migrate could not create the shadow database. Please make sure the database user has permission to create databases. Read more about the shadow database (and workarounds) at https://pris.ly/d/migrate-shadow

Original error: 
create database is not supported
   0: migration_core::state::DevDiagnostic
             at migration-engine/core/src/state.rs:251

image

想请问各位大佬应该怎么解决呀?谢谢你们!!

Serverless Functions不成功

您好,我按照您的教程自己也部署了一套,页面正常,但是api请求不正常,我也有在vercel上正确配置环境变量。这是我部署的地址:https://cp-blog-umi.vercel.app/ ,当我进行api请求时返回的是一个html文档,
image
这种情况应该是Serverless没有成功部署,尚不清楚出错原因,我的项目地址是https://github.com/XiaoPingzi-Anhui/cp-blog-umi ,这个项目在我本地是正常运行的,本地请求正常,大佬们看看哪里出了问题,如何让部署在vercel上的项目请求正常

怎么改请求里的response headers里的contentType为application/json

我在umi框架里写的api接口怎么改请求里的response headers里的contentType为application/json

`import type { UmiApiRequest, UmiApiResponse } from "umi";
import fs from "fs";
import path from "path";

export default async function (req: UmiApiRequest, res: UmiApiResponse) {
switch (req.method) {
case "GET":
try {
const { id } = req.body;
const mdxPath = path.join(
process.cwd(),
"src/mdxFile",
${20231127}.mdx
);

    const mdxContent = fs.readFileSync(mdxPath, "utf8");

    res
      .status(200)
      .header("Content-Type", "application/json")
      .json({ content: mdxContent });
  } catch {
    res.status(500).header("Content-Type", "application/json").json({
      result: false,
      message: "报错",
    });
  }
  break;

}
}`

请求的接口response一直是这个
image
导致fetch的res.json()报错,

Serverless Function 如何部署到其他服务器上呢

部署到 vercel 上是一键式的,什么都不用操作,但是如果我想部署到其他的平台呢,或者是自己的服务器呢?有没有相关的教程呀,或者给点提示也行。

我说一下目前的思路,既然是 serverless 的,那我可以自己安装一下 serverless 环境,剩下的就是如何在这个环境下部署所有的 api 了,应该有相关的命令或者脚本,我查了一下 vercel deploy umijs,里面只说了流程并没有提到具体的部署细节,找不到其他资料了

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.