优化配置、readme
This commit is contained in:
parent
1685b0b03a
commit
7d5064bfcc
39
README.md
39
README.md
|
@ -1,3 +1,42 @@
|
|||
# gitlink-ssr版本
|
||||
|
||||
|
||||
#### node版本
|
||||
12.x
|
||||
#### ng配置
|
||||
|
||||
```
|
||||
if ($http_user_agent ~* "googlebot|Mediapartners-Google|bingbot|google-structured-data-testing-tool|baiduspider|360Spider|Sogou Spider|Yahoo! Slurp China|^$")
|
||||
{#判断如果是网络爬虫,转发到node服务器下
|
||||
proxy_pass http://www.test.com:3000;
|
||||
break;
|
||||
}
|
||||
```
|
||||
|
||||
#### 依赖安装、运行
|
||||
|
||||
```bash
|
||||
// 依赖
|
||||
npm install
|
||||
npm install pm2 -g
|
||||
|
||||
// 打包
|
||||
npm run build
|
||||
npm run build:server
|
||||
|
||||
// 启动服务
|
||||
npm run pm2
|
||||
|
||||
```
|
||||
或者
|
||||
```bash
|
||||
./build.sh
|
||||
```
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
<h3>前端react环境安装:</h3>
|
||||
<p>1、 安装node v6.9.x;此安装包含了node和npm。</p>
|
||||
<p>2、 安装cnpm(命令行): npm install -g cnpm --registry=https://registry.npm.taobao.org</p>
|
||||
|
|
|
@ -0,0 +1 @@
|
|||
export const url = process.env.NODE_ENV === 'production' ? 'https://www.gitlink.org.cn' : 'http://172.20.32.202:4000'
|
|
@ -1,12 +1,13 @@
|
|||
import express from "express";
|
||||
import "./window"
|
||||
import {render} from "./render";
|
||||
import { url } from "../config/ssrUrl";
|
||||
const { createProxyMiddleware } = require('http-proxy-middleware');
|
||||
|
||||
const app = express();
|
||||
app.use('/build', express.static('build'));
|
||||
|
||||
const targetServer = 'http://172.20.32.202:4000'; // Java 服务器的地址
|
||||
const targetServer = url; // Java 服务器的地址
|
||||
const options = {
|
||||
target: targetServer,
|
||||
changeOrigin: true, // 允许在请求头中更改主机
|
||||
|
@ -37,7 +38,7 @@ app.get('*',function (req,res) {
|
|||
render(req,res);
|
||||
})
|
||||
|
||||
const port = 5000
|
||||
const port = 3000
|
||||
|
||||
console.log(`\n==> 🌎 Listening on port ${port}. Open up http://localhost:${port}/ in your browser.\n`)
|
||||
app.listen(port, '0.0.0.0');
|
|
@ -1,6 +1,7 @@
|
|||
import axios from 'axios';
|
||||
import { url } from '../../config/ssrUrl';
|
||||
|
||||
const baseUrl = 'http://172.20.32.202:4000/api'
|
||||
const baseUrl = `${url}/api`
|
||||
|
||||
//
|
||||
export async function getProjectFunc (owner, projectsId) {
|
||||
|
|
Loading…
Reference in New Issue