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

@jx3box/jx3box-fe-proxy

v1.0.1

Published

jx3box.com 前端开发域名前缀代理插件

Readme

jx3box.com 前端开发域名前缀代理插件

域名前缀代理功能

自动为带域名前缀的路径生成代理配置,内置常用域名,支持自定义扩展。

内置域名

插件内置以下常用域名,无需额外配置:

  • dev.next2 - 开发环境 next2
  • dev.team - 开发环境 team
  • pay - 支付服务
  • lua - Lua 脚本服务
  • next2 - next2 服务
  • team - 团队服务

功能说明

  • 前端请求/pay.jx3box.com/orders/123
  • 代理转发https://pay.jx3box.com/orders/123
  • 路径重写:自动移除域名前缀部分

在 Vue 项目中使用

基础使用(仅内置域名)
// vue.config.js
const VueProxyPlugin = require('@jx3box/jx3box-fe-proxy');

module.exports = {
    devServer: {
        proxy: {
            // 仅使用内置域名
            ...VueProxyPlugin.generateBuiltinProxy()
        },
        disableHostCheck: true,
    }
};
扩展使用(内置域名 + 自定义域名)
// vue.config.js
const VueProxyPlugin = require('@jx3box/jx3box-fe-proxy');

// 定义额外的自定义域名
const CUSTOM_DOMAINS = ['abc', 'def', 'dev.xyz'];

module.exports = {
    devServer: {
        proxy: {
            // 内置域名 + 自定义域名
            ...VueProxyPlugin.generateProxy(CUSTOM_DOMAINS)
        },
        disableHostCheck: true,
    }
};

代理工作原理

// 前端请求
fetch('/pay.jx3box.com/orders/123')          // 内置域名
fetch('/next2.jx3box.com/api/posts')         // 内置域名
fetch('/dev.team.jx3box.com/members')        // 内置域名
fetch('/abc.jx3box.com/users/list')          // 自定义域名

// 代理处理流程:
// 1. 匹配规则:/pay.jx3box.com、/next2.jx3box.com 等
// 2. 目标服务器:https://pay.jx3box.com、https://next2.jx3box.com 等
// 3. 路径重写:移除域名前缀部分
// 4. 最终请求:https://pay.jx3box.com/orders/123 等

生成的代理配置示例

{
  "/pay.jx3box.com": {
    "target": "https://pay.jx3box.com",
    "changeOrigin": true,
    "pathRewrite": {
      "^/pay.jx3box.com": ""
    },
    "onProxyReq": function (request) {
      request.setHeader("origin", "");
    }
  },
  "/next2.jx3box.com": {
    "target": "https://next2.jx3box.com",
    "changeOrigin": true,
    "pathRewrite": {
      "^/next2.jx3box.com": ""
    },
    "onProxyReq": function (request) {
      request.setHeader("origin", "");
    }
  },
  "/dev.team.jx3box.com": {
    "target": "https://dev.team.jx3box.com",
    "changeOrigin": true,
    "pathRewrite": {
      "^/dev.team.jx3box.com": ""
    },
    "onProxyReq": function (request) {
      request.setHeader("origin", "");
    }
  }
}

API 说明

VueProxyPlugin.generateProxy(domains, customProxy)

生成包含内置域名和自定义域名的完整代理配置。

  • domains: 自定义域名列表,如 ['abc', 'def', 'dev.xyz']
  • customProxy: 自定义代理配置(可选)

VueProxyPlugin.generateBuiltinProxy(customProxy)

仅生成内置域名的代理配置。

  • customProxy: 自定义代理配置(可选)

VueProxyPlugin.getBuiltinDomains()

获取内置域名列表。

使用示例

// 仅使用内置域名
const builtinProxy = VueProxyPlugin.generateBuiltinProxy();

// 内置域名 + 自定义域名
const fullProxy = VueProxyPlugin.generateProxy(['abc', 'def']);

// 获取内置域名列表
const builtinDomains = VueProxyPlugin.getBuiltinDomains();
console.log(builtinDomains); // ["dev.next2", "dev.team", "pay", "lua", "next2", "team"]

// 带自定义配置
const customProxy = VueProxyPlugin.generateProxy(
    ['abc'], 
    {
        '/api/external': {
            target: 'https://external.example.com',
            changeOrigin: true
        }
    }
);