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 🙏

© 2025 – Pkg Stats / Ryan Hefner

cors-sp

v0.1.5

Published

> 一个现代化、基于 ESM 的 CORS 代理服务,重构自 [cors-anywhere](https://github.com/Rob--W/cors-anywhere)。

Readme

cors-sp

一个现代化、基于 ESM 的 CORS 代理服务,重构自 cors-anywhere

✨ 功能特性

  • 现代架构:完全基于 ES Modules (ESM) 和最新的 Node.js 实践,无 CommonJS 依赖。
  • 核心代理功能:保持 cors-anywhere 的核心代理能力,解决跨域资源访问问题。
  • 清晰的模块化:项目结构经过精心设计,分为服务、代理处理、URL 解析、CORS 逻辑等模块,易于维护和扩展。
  • 开发友好:集成 nodemon 实现热重载,vitest 提供快速的单元测试体验。
  • 代码规范:使用 eslintprettier 保证代码风格一致性和高质量。

🚀 快速开始

  1. 安装依赖

    pnpm install
  2. 启动开发服务器

    pnpm dev

服务将默认启动在 http://localhost:4399

� Docker 支持

本项目提供了 Dockerfile,支持通过 Docker 进行构建和部署。

生产环境

构建并运行生产环境镜像:

# 构建镜像
docker build -t cors-sp:latest --target prod .

# 运行容器
docker run -d --name cors-sp -p 4399:4399 cors-sp:latest

开发与测试

你也可以使用 Docker 来运行测试:

# 构建开发环境镜像并运行测试
docker build -t cors-sp-dev --target dev .

�📁 目录结构

cors-sp/
├── src/
│   ├── server.js        # 服务器入口
│   ├── proxyHandler.js  # 核心代理逻辑
│   ├── urlParser.js     # URL 解析
│   ├── cors.js          # CORS 请求处理
│   └── utils.js         # 工具函数
├── test/
│   └── api.test.js      # API 测试
├── package.json
└── README.md

🛠️ 配置选项

  • originBlacklist / originWhitelist:来源黑/白名单,用于控制允许访问的来源。
  • requireHeader:要求请求中必须包含的头部字段。
  • removeHeaders / setHeaders:在转发请求前移除或设置特定的请求头。
  • checkRateLimit:自定义函数,用于实现速率限制。
  • redirectSameOrigin:当请求目标与代理同源时,执行重定向。

📜 产品迭代日志

v0.1.5 (2025-10-06)

  • 新增:根路径 http://localhost:4399/ 返回说明页。
  • 文档:更新 README.mddocs/quick-start.mddocs/server-usage.mddocs/api-reference.md
  • 兼容性:不影响代理路由与错误处理。

v0.1.0 (2025-09-04)

  • 项目初始化与重构
    • 使用 ESM 模块系统搭建项目基础架构。
    • 从原版 cors-anywhere 迁移核心逻辑,并进行现代化改造。
  • 核心功能实现
    • server.js: 创建并启动 HTTP 服务器。
    • proxyHandler.js: 实现核心反向代理功能,使用 http-proxy 转发请求。
    • cors.js: 增加 CORS 头部处理逻辑,以允许跨域请求。
    • urlParser.js: 添加 URL 解析和验证逻辑。
  • 开发与测试环境
    • 配置 nodemon 用于开发环境下的文件监听和服务器自动重启。
    • 集成 vitest 测试框架,并编写了基础的 API 测试用例 (api.test.js)。
  • 依赖现代化
    • 使用 tldjs 替代过时的 regexp-tld 用于顶级域名解析。
    • 引入 eslintprettier 来规范代码风格。

✅ 测试

运行以下命令来执行单元测试:

pnpm test

📄 许可证

MIT

提示:直接访问根路径 http://localhost:4399/ 将返回一页简要说明(文档页),用于快速检查服务运行状态与了解基本用法。

快速验证:

GET http://localhost:4399/                # 返回说明页
GET http://localhost:4399/https://api.github.com/users/octocat

变更摘要

  • 新增:访问根路径 http://localhost:4399/ 返回简要说明页,便于快速验证与了解用法。
  • 文档更新:同步 README.mddocs/quick-start.mddocs/server-usage.mddocs/api-reference.md