Skip to content

Commit

Permalink
更新默认环境为 http,增加配置 https 选项,更换开发服务器默认路由 (#57)
Browse files Browse the repository at this point in the history
* Update apiAddress.ts

更改前后端域名配置

* Update package.json

更新scripts中的start方式

* Update start.js

更新Host

* Update README.md

增加https的启动方式相关配置
  • Loading branch information
yd3826 authored Jul 30, 2024
1 parent 2b74e93 commit bb0c4fb
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 9 deletions.
6 changes: 4 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,10 @@ the https certificate for your local project.
mkcert -install
mkcert -key-file ./.cert/key.pem -cert-file ./.cert/cert.pem "localhost"
```
Change the start in package.json to "start": "cross-env HTTPS=true SSL_CRT_FILE=./.cert/cert.pem SSL_KEY_FILE=./.cert/key.pem node scripts/start.js".
Then,modify './src/utils/API/apiAddress.js' http to https in devlopment environment.

2. Install a proxy server for nginx, modify its configuration file,
3. Install a proxy server for nginx, modify its configuration file,
listen on ``8889`` as the SSL port, and forward routes ``\api`` to ``localhost:8080``.
```
server {
Expand All @@ -56,7 +58,7 @@ listen on ``8889`` as the SSL port, and forward routes ``\api`` to ``localhost:8
}
}
```
3. Run:
4. Run:

```shell
start nginx
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,7 @@
"yarn": "^1.22.19"
},
"scripts": {
"start": "cross-env HTTPS=true SSL_CRT_FILE=./.cert/cert.pem SSL_KEY_FILE=./.cert/key.pem node scripts/start.js",
"start": "node scripts/start.js",
"build": "node scripts/build.js",
"test": "node scripts/src.js/Test"
},
Expand Down
2 changes: 1 addition & 1 deletion scripts/start.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
// Do this as the first thing so that any code reading it knows the right env.
process.env.BABEL_ENV = 'development';
process.env.NODE_ENV = 'development';
process.env.HOST = 'oj.cs.sdu.edu.cn'
process.env.HOST = 'test.sduoj.com'

// Makes the script crash on unhandled rejections instead of silently
// ignoring them. In the future, promise rejections that are not handled will
Expand Down
10 changes: 5 additions & 5 deletions src/Utils/API/apiAddress.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,11 @@ export default function apiAddress() {
// SOCKET_SERVER: "ws://api.oj.cs.sdu.edu.cn:8080"
// }
if (process.env.NODE_ENV === 'development') return {
CLIENT_SERVER: 'https://oj.cs.sdu.edu.cn:' + port,
MANAGE_SERVER: 'https://oj.cs.sdu.edu.cn:' + port,
EXAM_SERVER: 'https://oj.cs.sdu.edu.cn:' + port,
FRONT_SERVER: 'https://oj.cs.sdu.edu.cn:3000',
SOCKET_SERVER: 'wss://oj.cs.sdu.edu.cn:' + port
CLIENT_SERVER: 'http://api.test.sduoj.com:' + port,
MANAGE_SERVER: 'http://api.test.sduoj.com:':' + port,
EXAM_SERVER: 'http://api.test.sduoj.com:':' + port,
FRONT_SERVER: 'http://test.sduoj.com:3000',
SOCKET_SERVER: 'ws://api.test.sduoj.com:':' + port
}
// return {
// CLIENT_SERVER: 'http://exam.yhf2000.cn:9000',
Expand Down

0 comments on commit bb0c4fb

Please sign in to comment.