# 本地代理服务器 **Repository Path**: KID1739180134/proxy-server ## Basic Information - **Project Name**: 本地代理服务器 - **Description**: 用node.js写的代理服务器,用来启动前端项目 - **Primary Language**: NodeJS - **License**: Not specified - **Default Branch**: master - **Homepage**: None - **GVP Project**: No ## Statistics - **Stars**: 0 - **Forks**: 0 - **Created**: 2022-03-06 - **Last Updated**: 2023-02-09 ## Categories & Tags **Categories**: Uncategorized **Tags**: None ## README # 用node写服务器过程 ### 1 创建一个文件夹,并在内部打开cmd命令行工具   ### 2 创建命令 ``` npm init ``` ### 3 输入服务器名称,然后一路回车 ``` server_name ``` ### 4 安装express插件(定义未知) ``` npm i express ``` ### 5 安装 解决history路由模式页面刷新404的问题 的插件 ``` npm i connect-history-api-fallback ``` ### 6 创建一个static文件夹,将打包后的htlm、css、js等打包好的文件放进去   ### 7 创建一个server.js文件,内容如下: ``` const express = require('express'); const history = require('connect-history-api-fallback'); const app = express(); app.use(history()); app.use(express.static(__dirname + '/static')); app.get('/ceshi',(req,res)=>{ res.send({ name: '短歌长眠', age: 25 }) }); app.listen(5005,err=>{ if(!err) console.log('服务器启动成功!'); }); ``` ### 8 启动命令 ``` node server ``` ### 9 在浏览器访问下面地址 ``` http://localhost:1412/ http://localhost:1412/index.html ```