Skip to content
This repository was archived by the owner on Jan 14, 2025. It is now read-only.

Commit 0df3ac7

Browse files
committed
Updated Amplify config with API Gateway region setting and added CORS headers to API 4xx and 5xx responses
1 parent e63a270 commit 0df3ac7

File tree

3 files changed

+28
-9
lines changed

3 files changed

+28
-9
lines changed

Auth/2_ServerlessAPI/Optional-APIGateway-IAMAuth.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -112,9 +112,9 @@ Now that you've deployed the new authorizer configuration to production, all API
112112

113113
13. Return to your Wild Rydes app, sign in at */signin* if necessary, and attempt to request a ride.
114114

115-
14. You should receive an *Error finding unicorn*. If you open the developer console, you will see that we received a HTTP 401 error, which means it was an unauthorized request. To authenticate our requests properly, we need to send an Authorization header.
115+
14. You should receive an *Error finding unicorn*. If you open the developer console, you will see that we received a HTTP 401 error, which means it was an unauthorized request.
116116

117-
> If you at first still that you requests go through without any errors, try requesting a ride again in 30-60 seconds to allow the API Gateway changes to fully propagate.
117+
> If at first your requests go through without any errors, try requesting a ride again in 30-60 seconds to allow time for the API Gateway changes to fully propagate.
118118
119119
15. Go back to Cloud9 and open the */website/src/pages/MainApp.js* files.
120120

Auth/2_ServerlessAPI/ServerlessBackend.yaml

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -240,6 +240,24 @@ Resources:
240240
application/json: "{\"statusCode\": 200}"
241241
passthroughBehavior: "when_no_match"
242242
type: "mock"
243+
244+
GatewayResponse:
245+
Type: AWS::ApiGateway::GatewayResponse
246+
Properties:
247+
ResponseParameters:
248+
gatewayresponse.header.Access-Control-Allow-Origin: "'*'"
249+
gatewayresponse.header.Access-Control-Allow-Headers: "'*'"
250+
ResponseType: DEFAULT_4XX
251+
RestApiId: !Ref WildRydesApi
252+
253+
GatewayResponse:
254+
Type: AWS::ApiGateway::GatewayResponse
255+
Properties:
256+
ResponseParameters:
257+
gatewayresponse.header.Access-Control-Allow-Origin: "'*'"
258+
gatewayresponse.header.Access-Control-Allow-Headers: "'*'"
259+
ResponseType: DEFAULT_5XX
260+
RestApiId: !Ref WildRydesApi
243261

244262
WildRydesApiDeployment:
245263
Type: AWS::ApiGateway::Deployment

Auth/website/src/amplify-config.js

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -5,22 +5,23 @@
55

66
const awsConfig = {
77
Auth: {
8-
identityPoolId: '', // EXAMPLE: 'us-east-1:5109bd6b-38ab-4429-89f8-e74d93656224'
9-
region: '', // EXAMPLE: 'us-east-1'
10-
userPoolId: '', // EXAMPLE: 'us-east-1_bgZVERFot'
11-
userPoolWebClientId: '' // EXAMPLE: '4lu058ri9ntkfrv99aa2taeu01'
8+
identityPoolId: '', // example: 'us-east-2:c85f3c18-05fd-4bb5-8fd1-e77e7627a99e'
9+
region: '', // example: 'us-east-2'
10+
userPoolId: '', // example: 'us-east-2_teEUQbkUh'
11+
userPoolWebClientId: '' // example: '3k09ptd8kn8qk2hpk07qopr86'
1212
},
1313
API: {
1414
endpoints: [
1515
{
1616
name: 'WildRydesAPI',
17-
endpoint: '' // EXAMPLE: https://1ngrgqjt6c.execute-api.us-east-1.amazonaws.com/prod
17+
endpoint: '', // example: 'https://u8swuvl00f.execute-api.us-east-2.amazonaws.com/prod'
18+
region: '' // example: 'us-east-2'
1819
}
1920
]
2021
},
2122
Storage: {
22-
bucket: '', //EXAMPLE: Amazon S3 bucket 'wildrydes-profile-images'
23-
region: '', // EXAMPLE: 'us-east-1'
23+
bucket: '', //example: 'wildrydesbackend-profilepicturesbucket-1wgssc97ekdph'
24+
region: '' // example: 'us-east-2'
2425
}
2526
}
2627

0 commit comments

Comments
 (0)