npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

u32-local-server

v1.1.0

Published

Local HTTP file server and proxy

Downloads

191

Readme

u32-local-server

本地 HTTP 文件服务器 + CORS 代理,纯 Node.js 零依赖。

功能特性

  • 📁 本地文件访问 - 通过 HTTP 访问本地文件系统
  • 🌐 CORS 代理 - 绕过跨域限制,代理任意 HTTP/HTTPS 请求
  • 🔐 权限控制 - 白名单/黑名单机制控制文件访问
  • 🎨 可视化配置 - Web 界面管理所有配置
  • 🚀 开机自启 - 支持注册为系统服务
  • 📋 右键菜单 - Windows 集成文件/文件夹右键菜单
  • 📺 目录浏览 - 美观的目录列表页面

快速开始

安装

npm install -g u32-local-server

启动服务器

# 启动服务器(后台运行)
u32-ls start

# 停止服务器
u32-ls stop

# 开发模式(前台运行,监听文件变化)
npm run dev

默认端口 19527,启动后访问:

  • 配置页面:http://localhost:19527/config

使用场景

1. 访问本地文件

直接通过浏览器访问:

  • Linux 用户目录:http://localhost:19527/file/~/
  • Linux 绝对路径:http://localhost:19527/file/home/user/file.txt
  • Windows 盘符:http://localhost:19527/file/C:/Users/user/file.txt

或者使用命令行工具:

# 获取文件/目录 URL
u32-ls url /path/to/file

# 在浏览器中打开
u32-ls open /path/to/file

# 复制 URL 到剪贴板
u32-ls copy-url /path/to/file

2. CORS 代理

用于绕过浏览器的跨域限制:

// 原始 URL(可能有跨域问题)
fetch('https://api.example.com/data')

// 使用代理(无跨域问题)
fetch('http://localhost:19527/proxy/https://api.example.com/data')

代理特性:

  • 删除 accept-encoding 头(返回未压缩内容)
  • 删除 x-frame-options 头(允许 iframe 嵌入)
  • 注入 CORS 头(允许跨域访问)
  • 支持所有 HTTP 方法(GET/POST/PUT/DELETE/PATCH 等)

配置

配置文件

位置:~/.u32-local-server/config/main.json

首次启动自动创建,默认配置:

{
  "port": 19527,
  "file": {
    "access": {
      "allow": [],
      "deny": []
    },
    "mime": {
      ".html": "text/html",
      ".js": "text/javascript",
      ".png": "image/png"
      // ... 更多 MIME 类型
    }
  },
  "proxy": {}
}

权限模型

  • allow: 白名单,允许访问的路径前缀
  • deny: 黑名单,拒绝访问的路径前缀
  • 优先级: deny > allow(黑名单优先)
  • allow 为空时,拒绝访问所有文件(白名单模式)
  • 路径支持 ~/ 表示用户主目录

示例:

{
  "file": {
    "access": {
      "allow": ["~/", "/mnt/data"],
      "deny": ["~/敏感文件夹", "/etc"]
    }
  }
}

配置页面

访问 http://localhost:19527/config 可视化管理:

  • 修改端口号
  • 添加/删除访问规则
  • 自定义 MIME 类型

命令参考

| 命令 | 说明 | |---|---| | u32-ls start | 启动后台服务器 | | u32-ls stop | 停止服务器 | | u32-ls restart | 重启服务器 | | u32-ls status | 查看服务器状态 | | u32-ls logs [-f] | 查看服务器日志 | | u32-ls url <path> | 获取文件 URL | | u32-ls open <path> | 在浏览器中打开 | | u32-ls copy-url <path> | 复制 URL 到剪贴板 | | u32-ls register | 注册开机自启 + 右键菜单 | | u32-ls unregister | 取消注册 | | u32-ls version | 显示版本号 | | u32-ls --help | 显示帮助信息 |

系统集成

Windows

运行 u32-ls register 后:

  • 开机自启: 注册到注册表 Run
  • 文件右键菜单:
    • 「在浏览器中打开」- 直接在浏览器打开文件
    • 「复制 URL」- 复制文件的访问 URL
  • 文件夹右键菜单:
    • 「在浏览器中打开」- 在浏览器浏览文件夹
    • 「复制 URL」- 复制文件夹的访问 URL
  • 文件夹背景右键:
    • 「在浏览器中打开当前目录」- 快速打开当前文件夹

Linux

运行 u32-ls register 后:

  • systemd 服务: 创建用户级服务(需要 sudo)
  • 开机自启: 用户登录时自动启动服务

路由表

| 路由 | 功能 | |---|---| | /proxy/<url> | CORS 代理 | | /config | 配置管理页面 | | /config/api | 配置 REST API | | /file/<path> | 文件访问(Windows 盘符/~/ 支持)| | / | 直接映射到文件系统(Linux) |

技术架构

  • 纯 Node.js - 零依赖,无第三方包
  • HTTP 服务器 - 使用原生 http 模块
  • 路径处理 - 自动识别 Windows 盘符和 ~
  • MIME 类型 - 内置 60+ 文件类型支持

开发

# 克隆项目
git clone <repo>
cd u32-local-server

# 开发模式(监听文件变化)
npm run dev

# 手动启动
node src/index.js start

许可证

MIT