![Oracle Drags Its Feet in the JavaScript Trademark Dispute](https://cdn.sanity.io/images/cgdhsj6q/production/919c3b22c24f93884c548d60cbb338e819ff2435-1024x1024.webp?w=400&fit=max&auto=format)
Security News
Oracle Drags Its Feet in the JavaScript Trademark Dispute
Oracle seeks to dismiss fraud claims in the JavaScript trademark dispute, delaying the case and avoiding questions about its right to the name.
@mocks-server/plugin-proxy
Advanced tools
Plugin for Mocks Server that provides a variant handler that proxy requests to another host and pass response back to original caller.
It uses the express-http-proxy package under the hood, and supports all of its options.
Important: From v3.0.0, this plugin includes two route handlers:
proxy
andproxy-v4
. This was made to allow Mocks Server v3 users to progressively adapt their code to Mocks Server v4 without breaking changes. It is strongly recommended to use theproxy-v4
handler. In the next major release, backward compatibilty will be removed and theproxy
handler will be replaced byproxy-v4
.
proxy-v4
handlerThis plugin is included in the main distribution of the Mocks Server project, so you can also read the official documentation website.
If you want a route variant to use the proxy-v4
handler, define its handler
property as "proxy-v4". Use the host
property to set the host for the route, and the options
property to set any of the express-http-proxy options.
module.exports = [
{
id: "proxy-all",
url: "*",
method: ["GET", "POST", "PATCH", "PUT"],
variants: [
{
id: "proxy-to-google",
type: "proxy-v4", // This route variant will use the "proxy" handler from this plugin
options: {
host: "https://www.google.com", // proxy host
options: {}, // Options for express-http-proxy
},
},
],
},
];
Here are listed the specific properties that can be defined in a proxy-v4
route variant. They must be defined in the options
property of the variant:
host
(String|Function): The proxy host. Equivalent to the express-http-proxy
host
option, so it can also be a function.options
(Object): Object containing any of the options supported by the express-http-proxy
package. Some of them are:
filter
option for express-http-proxy
.userResDecorator
option for express-http-proxy
.express-http-proxy
options are also supported.Tip: Note that the variant
delay
option is still valid for routes handled by this plugin, so you can use it to simulate that host responses are slow.
proxy
handlerIf you want a Mocks Server v3 route variant to use the proxy
handler, define its type
property as "proxy". Use the host
property to set the host for the route, and the options
property to set any of the express-http-proxy options.
module.exports = [
{
id: "proxy-all",
url: "*",
method: ["GET", "POST", "PATCH", "PUT"],
variants: [
{
id: "proxy-to-google",
type: "proxy", // This route variant will use the "proxy" handler from this plugin
host: "https://www.google.com", // proxy host
options: {}, // Options for express-http-proxy
},
],
},
];
Mocks server common properties to all route handlers are in cursive. Specific properties of this plugin are in bold:
host
(String|Function): The proxy host. Equivalent to the express-http-proxy
host
option, so it can also be a function.options
(Object): Object containing any of the options supported by the express-http-proxy
package. Some of them are:
filter
option for express-http-proxy
.userResDecorator
option for express-http-proxy
.express-http-proxy
options are also supported.Tip: Note that the
delay
option is still valid for routes handled by this plugin, so you can use it to simulate that host responses are slow.
FAQs
Mocks Server plugin providing proxy variant handler
The npm package @mocks-server/plugin-proxy receives a total of 0 weekly downloads. As such, @mocks-server/plugin-proxy popularity was classified as not popular.
We found that @mocks-server/plugin-proxy demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
Oracle seeks to dismiss fraud claims in the JavaScript trademark dispute, delaying the case and avoiding questions about its right to the name.
Security News
The Linux Foundation is warning open source developers that compliance with global sanctions is mandatory, highlighting legal risks and restrictions on contributions.
Security News
Maven Central now validates Sigstore signatures, making it easier for developers to verify the provenance of Java packages.