Search icon CANCEL
Arrow left icon
Explore Products
Best Sellers
New Releases
Books
Videos
Audiobooks
Learning Hub
Conferences
Free Learning
Arrow right icon
Arrow up icon
GO TO TOP
Building Serverless Python Web Services with Zappa

You're reading from   Building Serverless Python Web Services with Zappa Build and deploy serverless applications on AWS using Zappa

Arrow left icon
Product type Paperback
Published in Jul 2018
Publisher Packt
ISBN-13 9781788837613
Length 324 pages
Edition 1st Edition
Languages
Tools
Concepts
Arrow right icon
Author (1):
Arrow left icon
Abdulwahid Abdulhaque Barguzar Abdulwahid Abdulhaque Barguzar
Author Profile Icon Abdulwahid Abdulhaque Barguzar
Abdulwahid Abdulhaque Barguzar
Arrow right icon
View More author details
Toc

Table of Contents (15) Chapters Close

Preface 1. Amazon Web Services for Serverless FREE CHAPTER 2. Getting Started with Zappa 3. Building a Flask Application with Zappa 4. Building a Flask-Based REST API with Zappa 5. Building a Django Application with Zappa 6. Building a Django REST API with Zappa 7. Building a Falcon Application with Zappa 8. Custom Domain with SSL 9. Asynchronous Task Execution on AWS Lambda 10. Advanced Zappa Settings 11. Securing Serverless Applications with Zappa 12. Zappa with Docker 13. Assessments 14. Other Books You May Enjoy

Enabling CORS


Cross-Origin Resource Sharing (CORS) is an essential part of serving the API over the same domain or a different hosted domain. The AWS API Gateway provides a feature to enable CORS functionality. Once you have configured an API resource on an API Gateway, you must enable CORS using the API Gateway web console. Enabling CORS over API Gateway resources requires that you set the OPTION method with some response headers, such as the following:

  • Access-Control-Allow-Methods
  • Access-Control-Allow-Headers
  • Access-Control-Allow-Origin

You can take a look at the manual process of configuring CORS in the API Gateway in AWS's official documentation (https://docs.aws.amazon.com/apigateway/latest/developerguide/how-to-cors.html). 

Zappa automates the process of configuring CORS with API Gateway resources by using a setting attribute called cors, as mentioned in the following code snippet:

{
    "dev": {
             ...
             "cors": true/false
             ...
     }
}

Zappa sets the default...

lock icon The rest of the chapter is locked
Register for a free Packt account to unlock a world of extra content!
A free Packt account unlocks extra newsletters, articles, discounted offers, and much more. Start advancing your knowledge today.
Unlock this book and the full library FREE for 7 days
Get unlimited access to 7000+ expert-authored eBooks and videos courses covering every tech area you can think of
Renews at €18.99/month. Cancel anytime