aws / aws/aws-appsync-community

Question: How to setup cors policy in Appsync

Open
#318 2 comments 0 reactions 0 assignees View on GitHub
question
Dominant language
HTML
Stars
507
Forks
37
PR merge metrics
No merged PRs in 30d

Description

I have created a form using Nextjs + AWS Appsync API, I want to embed that form into another website (WordPress) , While submitting the website send a status code 401, I have not set up a cors policy on my API.Neither I can find a setting in my AWS console to add Cors for app sync , my stack code:-
```
// Create the AppSync GraphQL API
const api = new sst.AppSyncApi(this, 'graphql', {
graphqlApi: {
schema: schemas,
authorizationConfig: {
defaultAuthorization: {
authorizationType: AuthorizationType.USER_POOL,
userPoolConfig: {
userPool: userPol,
defaultAction: UserPoolDefaultAction.ALLOW,
},
},
additionalAuthorizationModes: [
{
authorizationType: AuthorizationType.API_KEY,
apiKeyConfig: {
expires: Expiration.after(Duration.days(365)),
},
},
],
},
},
defaultFunctionProps: {
timeout: 60,
environment: {
SENDER_EMAIL: SENDER_EMAIL || '',
DATABASE: ``,
USER_POOL_ID: USER_POOL_ID,
SNS_ORIGINAL_NUMBER: SNS_ORIGINAL_NUMBER,
GRAPHQL_API_URL: process.env.GRAPHQL_API_URL || '',
GRAPHQL_API_KEY: process.env.GRAPHQL_API_KEY || '',
ONESIGNAL_API_KEY: process.env.ONESIGNAL_API_KEY || '',
ONESIGNAL_APP_ID: process.env.ONESIGNAL_APP_ID || '',
DISTRIBUTION_ID: DISTRIBUTION_ID || '',
FRONTEND_URL,
STAGE: scope.stage,
USERS_FORM_SLUG,
},
},
dataSources: dataSources,
resolvers: { ...resolvers },
});
```

Contributor guide

Open the contributing guide

Research direction

Start with the AppSyncApi entry point and its graphqlApi authorizationConfig, then compare the request from the Next.js form embedded in WordPress with the configured USER_POOL and API_KEY modes. Reproduce the 401 response and consult the AppSync CORS and authorization behavior. Done means the embedded form can submit successfully or the required configuration is clearly identified.

Written by the indexing model from the issue text.

Assessment

Tech stack
aws, graphql, nextjs, wordpress
Domain
api, cloud, security
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.