I’m new to workers and trying to find some boiler plate help so i can script a worker that:
- handles a cors (cross domain request)
- handles a post request
- reads the json body string
- adds a property to the the json
- forwards it to a new url on my server intact as a post request
Is this possible?
This boilerplate CORS script might help you get started: Handling preflight requests
That performs steps 1-3 in your list. Most of the modifications you’d need to make steps 4 and 5 work would be in the
handlePost() function, though you may wish to remove the GET/HEAD pass-through behavior, too.