This is a Next.js project bootstrapped with create-next-app
.
curl --location 'http://localhost:3000/api/middleware/fetch' \
--header 'Content-Type: application/json' \
--data '{
"fetchParams": {
"apiUrl": "http://127.0.0.1:6806/api/system/version",
"fetchOptions": {
"method": "POST"
}
}
}'
{
"headers": {
"status": 200,
"statusText": "OK"
},
"body": {
"code": 0,
"msg": "",
"data": "2.10.14"
}
}
curl --location 'http://localhost:3000/api/prismjs' \
--header 'Content-Type: application/json' \
--data '{
"html": "<h1>这是一篇测试文章请忽略</h1>\n<p>这是测试的文字,如有打扰请谅解。稍后测试完毕会删除</p>\n<p></p>\n<p></p>\n<p>测试代码块</p>\n<p></p>\n<pre><code class=\"language-java\">public static void main();}\n</code></pre>\n"
}'
{
"html": "<pre class=\"code-block\" data-language=\"java\"><code class=\"hljs prism language-java\"><span class=\"token keyword\">public</span> <span class=\"token keyword\">static</span> <span class=\"token keyword\">void</span> <span class=\"token function\">main</span><span class=\"token punctuation\">(</span><span class=\"token class-name\">String</span><span class=\"token punctuation\">[</span><span class=\"token punctuation\">]</span>args<span class=\"token punctuation\">)</span><span class=\"token punctuation\">{</span><span class=\"token class-name\">System</span><span class=\"token punctuation\">.</span>out<span class=\"token punctuation\">.</span><span class=\"token function\">println</span><span class=\"token punctuation\">(</span><span class=\"token string\">\"Hello,World!\"</span><span class=\"token punctuation\">)</span><span class=\"token punctuation\">}</span></code></pre>"
}
1、新增 prismjs 服务,支持动态渲染高亮代码块为 html
1、fetch 代理新增 xml-body 支持
1、返回结果支持 cookie。后续所有 cors 对应的 header 统一放在 body 的 "cors-received-headers" 字段
2、支持 cookie 解析
3、升级 next.js 到 v14
1、jieba 更换为 node-rs
2、docker 更换为国内镜像。
3、新增调用 curl
调用实例
1、新增image代理
1、新增xmlrpc代理
2、新增fetch代理
1、新增中文分词服务
1、新增Google翻译服务
environment:
node = 16.20.2
First, run the development server:
npm run dev
# or
yarn dev
Open http://localhost:3000 with your browser to see the result.
You can start editing the page by modifying pages/index.tsx
. The page auto-updates as you edit the file.
API routes can be accessed on http://localhost:3000/api/hello. This endpoint can be edited in pages/api/hello.ts
.
The pages/api
directory is mapped to /api/*
. Files in this directory are treated as API routes instead of React pages.
This project uses next/font
to automatically optimize and load Inter, a custom Google Font.
docker run -itd --name=metaweblog-api -p 6333:3000 -e TZ=Asia/Shanghai --restart=unless-stopped nn200433/metaweblog-api:latest
version: '3'
services:
metaweblog-api:
image: nn200433/metaweblog-api:latest
container_name: metaweblog-api
restart: unless-stopped
ports:
- 6333:3000
environment:
- TZ=Asia/Shanghai
The nginx docker installation can be done using:
server {
# modify
server_name <your domain>;
listen 443 ssl http2;
# modify
ssl_certificate <your ssl pem file path>;
ssl_certificate_key <your ssl key file path>;
ssl_protocols TLSv1 TLSv1.1 TLSv1.2 TLSv1.3;
listen 80;
if ($scheme = http) {
return 301 https://$host:443$request_uri;
}
underscores_in_headers on;
# blog
location / {
proxy_pass http://127.0.0.1:8080;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Host $http_host;
proxy_set_header X-Forwarded-Port $server_port;
proxy_set_header X-Forwarded-Proto $scheme;
proxy_redirect http:// https://;
}
# metaweblog-api
location /api {
proxy_pass http://127.0.0.1:6333;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Host $http_host;
proxy_set_header X-Forwarded-Port $server_port;
proxy_set_header X-Forwarded-Proto $scheme;
proxy_redirect http:// https://;
}
}
To learn more about Next.js, take a look at the following resources:
- Next.js Documentation - learn about Next.js features and API.
- Learn Next.js - an interactive Next.js tutorial.
You can check out the Next.js GitHub repository - your feedback and contributions are welcome!
The easiest way to deploy your Next.js app is to use the Vercel Platform from the creators of Next.js.
Check out our Next.js deployment documentation for more details.