Skip to content

Commit

Permalink
docs: add more on nuxt docs [skip ci]
Browse files Browse the repository at this point in the history
  • Loading branch information
posva committed Jul 27, 2020
1 parent f99d313 commit 70f1c31
Showing 1 changed file with 15 additions and 0 deletions.
15 changes: 15 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -119,6 +119,21 @@ Automatically proxy cookies and headers on the server.
module.exports = {
buildModules: ['mande/nuxt']
}
```

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

Expand Down

0 comments on commit 70f1c31

Please sign in to comment.