Skip to content

Commit d333529

Browse files
authored
rework the examples a bit
1 parent 9fd39bd commit d333529

File tree

1 file changed

+13
-3
lines changed

1 file changed

+13
-3
lines changed

README.md

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -47,12 +47,16 @@ If this desribes your situation, then you need to proxy for local development. R
4747

4848
### Proxying for local development
4949

50+
> ⚠️IMPORTANT! PLEASE READ THIS ESPECIALLY IF YOU HAVE CORS ISSUES⚠️
51+
5052
When your function is deployed on Netlify, it will be available at `/.netlify/functions/function-name` for any given deploy context. It is advantageous to proxy the `netlify-lambda serve` development server to the same path on your primary development server.
5153

5254
Say you are running `webpack-serve` on port 8080 and `netlify-lambda serve` on port 9000. Mounting `localhost:9000` to `/.netlify/functions/` on your `webpack-serve` server (`localhost:8080/.netlify/functions/`) will closely replicate what the final production environment will look like during development, and will allow you to assume the same function url path in development and in production.
5355

54-
- See [netlify/create-react-app-lambda](https://github.com/netlify/create-react-app-lambda/blob/f0e94f1d5a42992a2b894bfeae5b8c039a177dd9/src/setupProxy.js) for an example of how to do this with `create-react-app`. [setupProxy is partially documented in the CRA docs](https://facebook.github.io/create-react-app/docs/proxying-api-requests-in-development#configuring-the-proxy-manually).
55-
- If you are using Gatsby, see [their Advanced Proxying docs](https://www.gatsbyjs.org/docs/api-proxy/#advanced-proxying)
56+
- If you are using with `create-react-app`, see [netlify/create-react-app-lambda](https://github.com/netlify/create-react-app-lambda/blob/f0e94f1d5a42992a2b894bfeae5b8c039a177dd9/src/setupProxy.js) for an example of how to do this with `create-react-app`. [setupProxy is partially documented in the CRA docs](https://facebook.github.io/create-react-app/docs/proxying-api-requests-in-development#configuring-the-proxy-manually).
57+
- If you are using Gatsby, see [their Advanced Proxying docs](https://www.gatsbyjs.org/docs/api-proxy/#advanced-proxying). This is implemented in the [JAMstack Hackathon Starter](https://github.com/sw-yx/jamstack-hackathon-starter).
58+
- If you are using Next.js, see [this issue for how to proxy](https://github.com/netlify/netlify-lambda/pull/28#issuecomment-439675503).
59+
- If you are using with Angular CLI, see the instructions below.
5660

5761
[Example webpack config](https://github.com/imorente/netlify-functions-example/blob/master/webpack.development.config):
5862

@@ -72,7 +76,10 @@ module.exports = {
7276

7377
The serving port can be changed with the `-p`/`--port` option.
7478

75-
## Using with `Angular CLI`
79+
<details>
80+
<summary>
81+
**Using with `Angular CLI`**
82+
</summary>
7683

7784
CORS issues when trying to use netlify-lambdas locally with angular? you need to set up a proxy.
7885

@@ -116,6 +123,7 @@ To make your life easier you can add these to your `scripts` in `package.json`
116123
```
117124

118125
Obviously you need to run up `netlify-lambda` & `angular` at the same time.
126+
<details>
119127

120128
## Webpack Configuration
121129

@@ -172,6 +180,8 @@ If you need an escape hatch and are building your lambda in some way that is inc
172180

173181
To debug lambdas, prepend the `serve` command with [npm's package runner npx](https://medium.com/@maybekatz/introducing-npx-an-npm-package-runner-55f7d4bd282b) `npx --node-arg=--inspect netlify-lambda serve ...`. Additionally, (1) make sure that sourcemaps are built along the way (e.g. in the webpack configuration and the `tsconfig.json` if typescript is used) and (2) webpack's uglification is turned off with `optimization: { minimize: false }`. If using VSCode, it is likely that the `sourceMapPathOverrides` have to be adapted for breakpoints to work.
174182

183+
Don't forget to search our issues in case someone has run into a similar problem you have!
184+
175185
## Netlify Identity
176186

177187
Netlify Identity is [not supported at the moment](https://github.com/netlify/netlify-lambda/issues/51) inside `netlify-lambda` function emulation, but for now you can [read the docs](https://www.netlify.com/docs/functions/#identity-and-functions) on how they should work.

0 commit comments

Comments
 (0)