aws-samples / aws-serverless-workshops

Code and walkthrough labs to set up serverless applications for Wild Rydes workshops
http://wildrydes.com
Apache License 2.0
4.2k stars 2.63k forks source link

an error occurred when requesting your unicorn undefined WildRydes #301

Open swardet opened 3 years ago

swardet commented 3 years ago

*an error occurred when requesting your unicorn: undefined

From https://aws.amazon.com/getting-started/hands-on/build-serverless-web-app-lambda-apigateway-s3-dynamodb-cognito/

Despite this issue being closed in April of 2018, something has changed since then, and it does not work. I've done this setup two times total and followed the instructions to the letter with a great attention to detail and it ends with the error "undefined" when you select the "Request Unicorn".

I can take the auth token from the /ride.html page to the API gateway > authorizers > paste as auth header > test and I get a 200 response code all day long. got this both times i finished the setup.

there's one thing in the setup that has changed. the setup says to use Node.js 6.10. but that is no longer available as an option. the first time i selected node.js 12.x and it didnt' work. the second time I selected node.js 10.x. still doesn't work.

I've seen all of what @mikedeck has had to say, and I can assure that I have spelled everything to the T. Mike has suggested that perhaps the function is named something different than RequestUnicorn. I can assure this isn't the case. For every single item in the module, I copied and pasted, and made sure there were no extra characters or spaces anywhere.

Mike makes mention of an invalid Authorization header at the URL at the end of this sentence(s), but I don't know how to make sure the same token I copied is actually getting passed in the Autorization HTTP header on the POST request made, because that's what the function(s) of the module(s) is supposed to do... take a logged in user's auth, then pass to the lambda functions with the cognito user pool and get a ride. here https://github.com/aws-samples/aws-serverless-workshops/issues/97#issuecomment-379103149

HELP?

*note: the word occurred is misspelled "An error occured..." error-occur

LiamYaoLian commented 3 years ago

I have a similar issue. Pretty sure I have enabled CORS.

Below is the error from the console. Could somebody help with this? Thanks very much!

DevTools failed to load SourceMap: Could not load content for https://master.dpv7asj2g73va.amplifyapp.com/js/vendor/amazon-cognito-identity.min.js.map: HTTP error: status code 404, net::ERR_HTTP_RESPONSE_CODE_FAILURE

DevTools failed to load SourceMap: Could not load content for https://master.dpv7asj2g73va.amplifyapp.com/js/vendor/aws-cognito-sdk.min.js.map: HTTP error: status code 404, net::ERR_HTTP_RESPONSE_CODE_FAILURE

ride.html:1 Access to XMLHttpRequest at 'https://aok4y2nap7.execute-api.us-east-2.amazonaws.com/prod/ride' from origin 'https://master.dpv7asj2g73va.amplifyapp.com' has been blocked by CORS policy: Response to preflight request doesn't pass access control check: No 'Access-Control-Allow-Origin' header is present on the requested resource.

ride.js:34 Error requesting ride: error , Details:
ajaxError @ ride.js:34 fire @ jquery-3.1.0.js:3243 fireWith @ jquery-3.1.0.js:3373 done @ jquery-3.1.0.js:9100 (anonymous) @ jquery-3.1.0.js:9332 error (async) send @ jquery-3.1.0.js:9360 ajax @ jquery-3.1.0.js:8999 requestUnicorn @ ride.js:19 handleRequestClick @ ride.js:82 dispatch @ jquery-3.1.0.js:5110 elemData.handle @ jquery-3.1.0.js:4918 ride.js:35 Response: undefined ajaxError @ ride.js:35 fire @ jquery-3.1.0.js:3243 fireWith @ jquery-3.1.0.js:3373 done @ jquery-3.1.0.js:9100 (anonymous) @ jquery-3.1.0.js:9332 error (async) send @ jquery-3.1.0.js:9360 ajax @ jquery-3.1.0.js:8999 requestUnicorn @ ride.js:19 handleRequestClick @ ride.js:82 dispatch @ jquery-3.1.0.js:5110 elemData.handle @ jquery-3.1.0.js:4918

mstachalski commented 3 years ago

Running into the same problem here, too.

ride.js:34 Error requesting ride: error , Details:
ajaxError @ ride.js:34

ride.js:35 Response: undefined ajaxError @ ride.js:35