-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'main' of https://github.com/xinyang424/coder-new-blog
- Loading branch information
Showing
56 changed files
with
1,757 additions
and
164 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -22,6 +22,7 @@ export default hopeTheme({ | |
Gmail: "mailto:[email protected]", | ||
Email: | ||
"https://wx.mail.qq.com/home/index?t=readmail_businesscard_midpage&nocheck=true&name=%E6%9D%A8%E6%96%B0&icon=https%3A%2F%2Fp.qlogo.cn%2Fqqmail_head%2FBkBjDTOZTuwDOcyvCy2I1B6zbGSkls5zqHIyibStOeqCDQia3zH2Nlgjdd3pibS09TD%2F160&mail=xinyang424%40qq.com&code=FwUG9hkLKs-dHLjnuWFlkk14SMS1VLiQ_XBJqksBPYpKOi6fWFNZbmUlTJGRZOMz10Lq6BqONi27BbmSEKOOKA", | ||
// 掘金: ["https://juejin.cn/user/4306129039670574/collections", "https://lf3-cdn-tos.bytescm.com/obj/static/xitu_juejin_web/static/favicons/apple-touch-icon.png"], | ||
}, | ||
}, | ||
// themeColor: { | ||
|
@@ -55,6 +56,7 @@ export default hopeTheme({ | |
createdTime: false, | ||
updatedTime: false, | ||
}, | ||
// 评论设置 | ||
comment: { | ||
provider: "Giscus", | ||
repo: "xinyang424/xinyang424.github.io", | ||
|
@@ -67,19 +69,21 @@ export default hopeTheme({ | |
// provider: "Waline", | ||
// serverURL: "https://blog.waline.coder-new.cn/", | ||
}, | ||
// 博客内容搜索功能 | ||
searchPro: true, | ||
|
||
mdEnhance: { | ||
align: true, | ||
attrs: true, | ||
codetabs: true, | ||
component: true, | ||
demo: true, | ||
figure: true, | ||
imgLazyload: true, | ||
imgSize: true, | ||
include: true, | ||
mark: true, | ||
align: true, // 自定义对齐 | ||
// attrs: true, // 属性支持 | ||
codetabs: true, // 代码块分组 | ||
component: true, // 组件 | ||
demo: true, // 代码演示 | ||
figure: true, // 渲染的图片下面添加描述,或者点击图片带跳转 | ||
imgLazyload: true, // 图片懒加载 | ||
imgSize: true, // 设置图片大小 如![Alt](图片路径 "图片标题" =宽x高) https://theme-hope.vuejs.press/zh/guide/markdown/grammar/image.html#%E9%AB%98%E7%BA%A7%E7%94%A8%E6%B3%95 | ||
// include: true,// 导入文件 | ||
alert: true, // GFM 警告 https://theme-hope.vuejs.press/zh/guide/markdown/stylize/alert.html | ||
mark: true, // 黄色标记 https://theme-hope.vuejs.press/zh/guide/markdown/stylize/mark.html | ||
stylize: [ | ||
{ | ||
matcher: "Recommended", | ||
|
@@ -93,10 +97,11 @@ export default hopeTheme({ | |
}, | ||
}, | ||
], | ||
sub: true, | ||
sup: true, | ||
tabs: true, | ||
vPre: true, | ||
|
||
// sub: true,// 下角标 https://theme-hope.vuejs.press/zh/guide/markdown/grammar/sup-sub.html | ||
// sup: true,// 上角标 https://theme-hope.vuejs.press/zh/guide/markdown/grammar/sup-sub.html | ||
tabs: true, // 选项卡 https://theme-hope.vuejs.press/zh/guide/markdown/content/tabs.html | ||
// vPre: true, // https://theme-hope.vuejs.press/zh/guide/markdown/others.html#gfm | ||
// revealJs: true, | ||
// 在启用之前安装 chart.js | ||
// chart: true, | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
--- | ||
title: CORS | ||
date: 2023-05-20 | ||
icon: cors | ||
order: 3 | ||
--- | ||
|
||
|
||
|
||
|
||
## 基于 Nodejs + Express 实践 | ||
|
||
自行封装 cors: | ||
```js | ||
const express = require('express'); | ||
const router = express.Router(); | ||
|
||
router.all('*', function (req, res, next) { | ||
/* 设置响应头,允许所有网站都可以请求,当然也可以进行白名单配置,运行哪些可以通过访问,其它不可通过访问 */ | ||
res.header('Access-Control-Allow-Origin', '*'); | ||
/* 设置我们的请求方式可以有以下这些 */ | ||
res.header('Access-Control-Allow-Methods', 'GET, POST, PUT, DELETE,OPTIONS'); | ||
/* 设置响应头可以有以下这些 */ | ||
res.header('Access-Control-Allow-Headers', 'Content-Type,Content-Length, Authorization, Accept,X-Requested-With,token'); | ||
/* 放行 */ | ||
req.method === 'OPTIONS' ? res.status(204).end() : next(); | ||
}); | ||
|
||
module.exports = router; | ||
``` | ||
|
||
使用的时候一定要在所有请求之前调用: | ||
```js | ||
const express = require('express'); | ||
const cors = require('./utils/cors'); | ||
const loginRouter = require('./routers/login'); | ||
|
||
//创建express服务 http | ||
const app = express(); | ||
|
||
app.use(cors);//解决跨域问题 | ||
|
||
// 使用路由 | ||
|
||
app.use('/login', loginRouter); | ||
``` |
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.