Socket
Socket
Sign inDemoInstall

mande

Package Overview
Dependencies
Maintainers
1
Versions
36
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

mande - npm Package Compare versions

Comparing version 0.0.12 to 0.0.13

7

CHANGELOG.md

@@ -0,1 +1,8 @@

## [0.0.13](https://github.com/posva/mande/compare/v0.0.12...v0.0.13) (2020-07-27)
### Bug Fixes
- **nuxt:** avoid hot reload error ([d47e46d](https://github.com/posva/mande/commit/d47e46d6a8817c075be9398d0102aa9d886af29e))
- ignore some headers when proxying ([f99d313](https://github.com/posva/mande/commit/f99d313c61e360ea5e6a5f19ce4d198e1fd4875a))
## [0.0.12](https://github.com/posva/mande/compare/v0.0.11...v0.0.12) (2020-07-23)

@@ -2,0 +9,0 @@

2

dist/mande.common.js
/*!
* mande v0.0.11
* mande v0.0.12
* (c) 2020 Eduardo San Martin Morote

@@ -4,0 +4,0 @@ * @license MIT

/*!
* mande v0.0.11
* mande v0.0.12
* (c) 2020 Eduardo San Martin Morote

@@ -4,0 +4,0 @@ * @license MIT

/*!
* mande v0.0.11
* mande v0.0.12
* (c) 2020 Eduardo San Martin Morote

@@ -4,0 +4,0 @@ * @license MIT

/*!
* mande v0.0.11
* mande v0.0.12
* (c) 2020 Eduardo San Martin Morote

@@ -4,0 +4,0 @@ * @license MIT

/*!
* mande v0.0.11
* mande v0.0.12
* (c) 2020 Eduardo San Martin Morote

@@ -4,0 +4,0 @@ * @license MIT

import path from 'path'
export default function NuxtMandeModule() {
const DEFAULT_OPTIONS = {
proxyHeadersIgnore: [
'accept',
'host',
'cf-ray',
'cf-connecting-ip',
'content-length',
'content-md5',
'content-type',
],
}
/** @type {import('@nuxt/types').Module} */
const MandeModule = function NuxtMandeModule(localOptions) {
// TODO: merge arrays properly. There is probably a package to handle this
const options = {
...DEFAULT_OPTIONS,
...localOptions,
}
this.addPlugin({
src: path.resolve(__dirname, 'plugin.js'),
fileName: 'mande.js',
options,
})
}

@@ -0,1 +1,2 @@

/** @type {import('@nuxt/types').Plugin} */

@@ -7,3 +8,18 @@ export default (ctx, inject) => {

(api) => {
api.options.headers = { ...api.options.headers, ...ctx.req.headers }
// the plugin can be called during dev in client side with no context
if (!ctx.req) return
const reqHeaders = { ...ctx.req.headers }
// @ts-ignore
for (let header of <%= serialize(options.proxyHeadersIgnore) %>) {
delete reqHeaders[header]
}
api.options.headers = { ...api.options.headers, ...reqHeaders }
if (process.server) {
// Don't accept brotli encoding because Node can't parse it
api.options.headers['accept-encoding'] = 'gzip, deflate'
}
},

@@ -10,0 +26,0 @@ ...args

{
"name": "mande",
"version": "0.0.12",
"version": "0.0.13",
"description": "Some awesome description",

@@ -5,0 +5,0 @@ "main": "dist/mande.common.js",

@@ -122,3 +122,18 @@ # mande [![Build Status](https://badgen.net/circleci/github/posva/mande/master)](https://circleci.com/gh/posva/mande) [![npm package](https://badgen.net/npm/v/mande)](https://www.npmjs.com/package/mande) [![coverage](https://badgen.net/codecov/c/github/posva/mande/master)](https://codecov.io/github/posva/mande) [![thanks](https://badgen.net/badge/thanks/♥/pink)](https://github.com/posva/thanks)

}
```
To make Mande work on Server, make sure to provide a `fetch` polyfill and to use full URLs and not absolute URLs starting with `/`. For example, using `node-fetch`, you can do:
```js
export const BASE_URL = process.server
? process.env.NODE_ENV !== 'production'
? 'http://localhost:3000'
: 'https://example.com'
// on client, do not add the domain, so urls end up like `/api/something`
: ''
const fetchPolyfill = process.server ? require('node-fetch') : fetch
const contents = mande(BASE_URL + '/api', {}, fetchPolyfill)
```
## API

@@ -125,0 +140,0 @@

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc