Skip to content

Commit 5a31117

Browse files
swyxiostefan--
authored andcommitted
Update README.md
1 parent dc581ee commit 5a31117

File tree

1 file changed

+8
-0
lines changed

1 file changed

+8
-0
lines changed

README.md

+8
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,14 @@ There are additional options, introduced later:
3737
-s --static
3838
```
3939

40+
## Using with `create-react-app`, Gatsby, and other development servers
41+
42+
`react-scripts` (the underlying library for `create-react-app`) and other popular development servers often set up catchall serving for you; in other words, if you try to request a route that doesn't exist, the dev server will try to serve you `/index.html`. This is problematic when you are trying to hit a local API endpoint like `netlify-lambda` sets up for you - your browser will attempt to parse the `index.html` file as JSON. This is why you may see this error:
43+
44+
`Uncaught (in promise) SyntaxError: Unexpected token < in JSON at position 0`
45+
46+
If this desribes your situation, then you need to proxy for local development. Read on. Don't worry it's easier than it looks.
47+
4048
### Proxying for local development
4149

4250
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.

0 commit comments

Comments
 (0)