reworks redirect documentation

Co-authored-by: Prince Wilson <maxcell.wilson@gmail.com>
This commit is contained in:
Tara Z. Manicsic 2022-02-18 23:24:04 -05:00 committed by GitHub
parent da11162a4d
commit 736cf98c12
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -20,7 +20,7 @@ $ npm run generate
In the [`netlify.toml`](./netlify.toml) configuration file there is an example of how to implement redirects. Redirects can be used to do many things from redirecting Single Page Apps more predictably, redirecting based on country/language to leveraging On-Demand Builders for [Distributed Persistant Rendering](https://www.netlify.com/blog/2021/04/14/distributed-persistent-rendering-a-new-jamstack-approach-for-faster-builds/).
In the example we'll be using redirects to have a more simplified call to Netlify functions. Technically when you call a function you will be making a call to `https://yoursite.netlify.com/.netlify/functions/functionName`. In order to make a cleaner path we'll redirect all calls from a path including `/api` to call on the Netlify functions. So the path will be simplified to `https://yoursite.netlify.com/api/functionName`, a lot easier to remember too.
In the example we'll be using redirects to have a shorter endpoint to Netlify functions. By default, you call a Netlify function when requesting a path like `https://yoursite.netlify.com/.netlify/functions/functionName`. Instead, we'll redirect all calls from a path including `/api` to call on the Netlify functions. So the path will be `https://yoursite.netlify.com/api/functionName`, a lot easier to remember too.
### Example