修复 public 服务转发

This commit is contained in:
whyour 2023-05-10 01:07:46 +08:00
parent 7c3bb90d12
commit 50718ba714
7 changed files with 2790 additions and 2387 deletions

View File

@ -15,12 +15,22 @@ import * as Sentry from '@sentry/node';
import { EnvModel } from '../data/env';
import { errors } from 'celebrate';
import path from 'path';
import { createProxyMiddleware } from 'http-proxy-middleware';
export default ({ app }: { app: Application }) => {
app.enable('trust proxy');
app.use(cors());
app.use(`${config.api.prefix}/static`, express.static(config.uploadPath));
app.use(
'/api/public',
createProxyMiddleware({
target: `http://localhost:${config.publicPort}/api`,
changeOrigin: true,
pathRewrite: { '/api/public': '' },
}),
);
app.use((req, res, next) => {
if (req.path.startsWith('/api') || req.path.startsWith('/open')) {
next();

View File

@ -10,6 +10,7 @@ echo -e "======================1. 检测配置文件========================\n"
make_dir /etc/nginx/conf.d
make_dir /run/nginx
init_nginx
fix_config
pm2 l &>/dev/null

View File

@ -72,6 +72,7 @@
"form-data": "^4.0.0",
"got": "^11.8.2",
"hpagent": "^0.1.2",
"http-proxy-middleware": "^2.0.6",
"iconv-lite": "^0.6.3",
"js-yaml": "^4.1.0",
"jsonwebtoken": "^8.5.1",

File diff suppressed because it is too large Load Diff

View File

@ -508,6 +508,5 @@ init_env
detect_termux
detect_macos
define_cmd
fix_config
import_config $1 2>$task_error_log_path

View File

@ -257,6 +257,9 @@ update_qinglong() {
cp -f $file_config_sample $dir_config/config.sample.sh
update_depend
[[ -f $dir_root/package.json ]] && ql_depend_new=$(cat $dir_root/package.json)
[[ "$ql_depend_old" != "$ql_depend_new" ]] && npm_install_2 $dir_root
update_qinglong_static "$1" "$primary_branch"
else
echo -e "\n更新青龙源文件失败请检查网络...\n"
@ -467,6 +470,7 @@ main() {
case $p1 in
update)
fix_config
eval update_qinglong "$2" $cmd
;;
extra)

View File

@ -27,7 +27,6 @@ const Error = () => {
}
retryTimes.current += 1;
setTimeout(() => {
reloadUser();
getLog(false);
}, 3000);
})