This commit is contained in:
2022-07-18 02:50:52 +00:00
parent befd344ab0
commit 06181b34d6
8569 changed files with 818704 additions and 352705 deletions
+14
View File
@@ -2,6 +2,20 @@
All notable changes to this project will be documented in this file. See [standard-version](https://github.com/conventional-changelog/standard-version) for commit guidelines.
## [2.1.0](https://github.com/nuxt-community/proxy-module/compare/v2.0.1...v2.1.0) (2020-12-14)
### Features
* update module (typescript rewrite) ([c9dad3c](https://github.com/nuxt-community/proxy-module/commit/c9dad3c547759ca05413b6d85087e80e468297a5))
### [2.0.1](https://github.com/nuxt-community/proxy-module/compare/v2.0.0...v2.0.1) (2020-07-16)
### Bug Fixes
* skip module for nuxt build (fixes [#74](https://github.com/nuxt-community/proxy-module/issues/74)) ([50db85e](https://github.com/nuxt-community/proxy-module/commit/50db85eb5dd76dd20fe146b282cc082de721663f))
## [2.0.0](https://github.com/nuxt-community/proxy-module/compare/v1.3.3...v2.0.0) (2020-06-03)
+7 -13
View File
@@ -2,16 +2,13 @@
[![npm version][npm-version-src]][npm-version-href]
[![npm downloads][npm-downloads-src]][npm-downloads-href]
[![Circle CI][circle-ci-src]][circle-ci-href]
[![Codecov][codecov-src]][codecov-href]
[![License][license-src]][license-href]
[![codecov][codecov-src]][codecov-href]
[![license][license-src]][license-href]
> The one-liner node.js http-proxy middleware solution for Nuxt.js using [http-proxy-middleware](https://github.com/chimurai/http-proxy-middleware)
> Proxy support for nuxt server
[📖 **Release Notes**](./CHANGELOG.md)
✨ Do you know that [Axios Module](https://github.com/nuxt-community/axios-module) has built in support for Proxy Module?
## Features
✓ Path rewrites
@@ -24,7 +21,7 @@
✓ Auth / Cookie
✓ ...and more! (see [http-proxy-middleware](https://github.com/chimurai/http-proxy-middleware) docs)
✓ ...See [http-proxy-middleware](https://github.com/chimurai/http-proxy-middleware) docs
⚠ Does not work in generated/static mode!
@@ -62,9 +59,9 @@ yarn add @nuxtjs/proxy # or npm install @nuxtjs/proxy
You can provide proxy config using either object or array.
### Array mode
### Array Config
You can use magic [shorthands](https://github.com/chimurai/http-proxy-middleware#shorthand)
You can use [shorthand syntax](https://github.com/chimurai/http-proxy-middleware#shorthand) to configure proxy:
```js
{
@@ -81,7 +78,7 @@ You can use magic [shorthands](https://github.com/chimurai/http-proxy-middleware
}
```
### Object mode
### Object Config
Keys are [context](https://github.com/chimurai/http-proxy-middleware#context-matching)
@@ -122,9 +119,6 @@ Copyright (c) Nuxt Community
[npm-downloads-src]: https://img.shields.io/npm/dt/@nuxtjs/proxy.svg?style=flat-square
[npm-downloads-href]: https://npmjs.com/package/@nuxtjs/proxy
[circle-ci-src]: https://img.shields.io/circleci/project/github/nuxt-community/proxy-module.svg?style=flat-square
[circle-ci-href]: https://circleci.com/gh/nuxt-community/proxy-module
[codecov-src]: https://img.shields.io/codecov/c/github/nuxt-community/proxy-module.svg?style=flat-square
[codecov-href]: https://codecov.io/gh/nuxt-community/proxy-module
+18
View File
@@ -0,0 +1,18 @@
import { Module } from '@nuxt/types';
import { Options, Filter } from 'http-proxy-middleware';
declare type ProxyContext = Filter | Options;
declare type ProxyOptionsObject = {
[target: string]: Options;
};
declare type ProxyOptionsArray = Array<[ProxyContext, Options?] | Options | string>;
declare type NuxtProxyOptions = ProxyOptionsObject | ProxyOptionsArray;
declare module '@nuxt/types' {
interface Configuration {
proxy?: NuxtProxyOptions;
}
}
declare const proxyModule: Module<Options>;
export default proxyModule;
+57
View File
@@ -0,0 +1,57 @@
'use strict';
const httpProxyMiddleware = require('http-proxy-middleware');
function getProxyEntries(proxyOptions, defaults) {
const applyDefaults = (opts) => ({...defaults, ...opts});
const normalizeTarget = (input) => typeof input === "object" ? input : {target: input};
const proxyEntries = [];
if (!proxyOptions) {
return proxyEntries;
}
if (!Array.isArray(proxyOptions)) {
for (const key in proxyOptions) {
proxyEntries.push({
context: key,
options: applyDefaults(normalizeTarget(proxyOptions[key]))
});
}
return proxyEntries;
}
for (const input of proxyOptions) {
if (Array.isArray(input)) {
proxyEntries.push({
context: input[0],
options: applyDefaults(normalizeTarget(input[1]))
});
} else {
proxyEntries.push({
context: input,
options: applyDefaults()
});
}
}
return proxyEntries;
}
const proxyModule = function(options2) {
const nuxt = this.nuxt;
if (!nuxt.options.server || !nuxt.options.proxy) {
return;
}
const defaults = {
changeOrigin: true,
ws: true,
...options2
};
const proxyEntries = getProxyEntries(nuxt.options.proxy, defaults);
for (const proxyEntry of proxyEntries) {
this.addServerMiddleware({
prefix: false,
handler: httpProxyMiddleware.createProxyMiddleware(proxyEntry.context, proxyEntry.options)
});
}
};
proxyModule.meta = require("../package.json");
module.exports = proxyModule;
+25 -32
View File
@@ -1,66 +1,57 @@
{
"_args": [
[
"@nuxtjs/proxy@2.0.0",
"/mnt/Foxconn/Digitalent/Deverloper/liff-push_2series"
"@nuxtjs/proxy@2.1.0",
"/home/node/nuxt"
]
],
"_from": "@nuxtjs/proxy@2.0.0",
"_id": "@nuxtjs/proxy@2.0.0",
"_from": "@nuxtjs/proxy@2.1.0",
"_id": "@nuxtjs/proxy@2.1.0",
"_inBundle": false,
"_integrity": "sha512-ewiOLAhfQlE/QWiQkHH0MQBYrtTRRSuz5SqDly1Zy/M3cN9bxqWd9d5Ty/GnU3nLtwsfW64TrRKuTw8/gT1nFQ==",
"_integrity": "sha512-/qtoeqXgZ4Mg6LRg/gDUZQrFpOlOdHrol/vQYMnKu3aN3bP90UfOUB3QSDghUUK7OISAJ0xp8Ld78aHyCTcKCQ==",
"_location": "/@nuxtjs/proxy",
"_phantomChildren": {},
"_requested": {
"type": "version",
"registry": true,
"raw": "@nuxtjs/proxy@2.0.0",
"raw": "@nuxtjs/proxy@2.1.0",
"name": "@nuxtjs/proxy",
"escapedName": "@nuxtjs%2fproxy",
"scope": "@nuxtjs",
"rawSpec": "2.0.0",
"rawSpec": "2.1.0",
"saveSpec": null,
"fetchSpec": "2.0.0"
"fetchSpec": "2.1.0"
},
"_requiredBy": [
"/@nuxtjs/axios"
],
"_resolved": "https://registry.npmjs.org/@nuxtjs/proxy/-/proxy-2.0.0.tgz",
"_spec": "2.0.0",
"_where": "/mnt/Foxconn/Digitalent/Deverloper/liff-push_2series",
"_resolved": "https://registry.npmjs.org/@nuxtjs/proxy/-/proxy-2.1.0.tgz",
"_spec": "2.1.0",
"_where": "/home/node/nuxt",
"bugs": {
"url": "https://github.com/nuxt-community/proxy-module/issues"
},
"contributors": [
{
"name": "Pooya Parsa",
"email": "pooya@pi0.ir"
}
],
"dependencies": {
"consola": "^2.11.3",
"http-proxy-middleware": "^1.0.4"
"http-proxy-middleware": "^1.0.6"
},
"description": "The one-liner node.js http-proxy middleware solution for Nuxt.js using http-proxy-middleware",
"description": "proxy support for nuxt server",
"devDependencies": {
"@commitlint/cli": "latest",
"@commitlint/config-conventional": "latest",
"@nuxtjs/eslint-config": "latest",
"codecov": "latest",
"@babel/preset-typescript": "^7.12.7",
"@nuxt/test-utils": "latest",
"@nuxt/types": "latest",
"@nuxtjs/eslint-config-typescript": "latest",
"eslint": "latest",
"husky": "latest",
"jest": "latest",
"nuxt-edge": "latest",
"request": "latest",
"request-promise-native": "latest",
"nuxt": "^2.14.11",
"siroc": "latest",
"standard-version": "latest"
},
"files": [
"lib"
"dist"
],
"homepage": "https://github.com/nuxt-community/proxy-module#readme",
"license": "MIT",
"main": "lib/module.js",
"main": "dist/index.js",
"name": "@nuxtjs/proxy",
"publishConfig": {
"access": "public"
@@ -70,10 +61,12 @@
"url": "git+https://github.com/nuxt-community/proxy-module.git"
},
"scripts": {
"build": "siroc build",
"dev": "nuxt test/fixture",
"lint": "eslint --ext .js,.vue lib test",
"lint": "eslint --ext .js,.vue,.ts .",
"release": "yarn test && standard-version && git push --follow-tags && npm publish",
"test": "yarn lint && jest"
},
"version": "2.0.0"
"types": "dist/index.d.ts",
"version": "2.1.0"
}