我的前端坑
  • 关于本书
  • CSS JS 常用
    • 常用 CSS 样式
    • 坑爹的 CSS
    • sass 入门
    • canvas 总结
    • 常用 JS 函数
    • 表单和 FormData 对象
    • 水平滑动 tab 居中
    • js 中的 this
    • sse 和 fetch
    • js 原型链与 class 类
  • TypeScript
    • TS 概念
    • interface 与 type
    • interface 接口
    • Ts 配合 ESLint 和 prettier
  • 小程序
    • 常用小程序代码
  • VUE
    • VUE2 小技巧
    • VUE-CLI 中的 NODE_ENV
  • VUE3
    • VUE3 自行构建 sfc 遇到的坑
    • VUE3 v-model 的实现
    • VUE3 使用总结
    • VUE3 ref
  • vite
    • vite
  • http 请求
    • 前端实现下载
    • cors 跨域请求
    • windows hosts 文件
    • err_blocked_by_client 错误
  • 前端工具
    • npm 和 Node
      • 常见问题
      • npmTips
      • package.json 与 package-lock.json
      • npx
      • exports 与 module.exports
      • ESLint
    • VIM
      • vim 常用
    • Git
      • Git 常用命令
      • Git 小 tips
    • express
  • 后端工具
    • mysql 常见问题
    • docker 常见问题
    • docker
  • java
    • java 常用
    • lambda 表达式
    • java 字符串
    • java 泛型
    • java 反射
    • intellij IDEA
    • 多态
    • java 包管理
    • sql 查询语言
    • java 反射
    • java 异常
    • java 集合
    • spring
  • 命令行
    • 命令行 常用
  • 专利撰写 ppt
  • 后台简述
Powered by GitBook
On this page

Was this helpful?

  1. http 请求

windows hosts 文件

有时候本地开发时,需要不同的项目同时绑定 localhost 想要使用 localhost+不同端口号来实现的话,可以使用如下方法: 以下在 hosts 文件内配置:

# ····
# localhost name resolution is handled within DNS itself.
#	127.0.0.1       localhost
#	::1             localhost

192.168.10.153 windows10.microdone.cn

# 本地项目1
127.0.0.1 toocool.com
127.0.0.1 toocool.com:3000

# 本地项目2
127.0.0.1 avatar.com
127.0.0.1 avatar.com:3001

这样配置好后,使用: 127.0.0.1:3000 localhost:3000 toocool.com:3000 访问的项目就是绑定本地 3000 端口的项目。

127.0.0.1:3000 localhost:3000 avatar.com:3000 访问的项目就是绑定本地 3001 端口的项目。

这样就可以同时使用 localhost 的不同端口绑定不同项目了。

Previouscors 跨域请求Nexterr_blocked_by_client 错误

Last updated 2 years ago

Was this helpful?