aws-amplify / aws-amplify/amplify-cli

Default DynamoDB template for functions should have CORS configured properly

Open
#8,075 1 comment 0 reactions 0 assignees View on GitHub
feature-request functions p4
Dominant language
TypeScript
Stars
2.9k
Forks
825
Avg merge
11d 23h
Merged PRs (30d)
2

Description

### Is this related to a new or existing Amplify category?

function

### Is this related to another service?

DynamoDB

### Describe the feature you'd like to request

When using the default DynamoDB template via `amplify add function`, I get a function without proper CORS configuration.

Leading to:
```
Access to XMLHttpRequest at 'the link*' from origin 'http://localhost:3000/' has been blocked by CORS policy: No 'Access-Control-Allow-Origin' header is present on the requested resource.
```

### Describe the solution you'd like

![image](https://user-images.githubusercontent.com/4989523/131599696-368d6e6e-2aeb-41a5-86a4-11b8659abc36.png)
The template above should be updated to have CORS properly considered.

Potentially with:
`npm install cors`
then in the code:
`app.use(cors())`

### Describe alternatives you've considered

Documentation updates but better to have this "just work".

### Additional context

_No response_

### Is this something that you'd be interested in working on?

- [ ] 👋 I may be able to implement this feature request
- [ ] ⚠️ This feature might incur a breaking change

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.