Closed funkfinger closed 6 years ago
Your app.js should have this in order to work on the browser.
// declare a new express app
var app = express()
app.use(bodyParser.json())
app.use(awsServerlessExpressMiddleware.eventContext())
// Enable CORS for all methods
app.use(function(req, res, next) {
res.header("Access-Control-Allow-Origin", "*")
res.header("Access-Control-Allow-Headers", "Origin, X-Requested-With, Content-Type, Accept")
next()
});
Have you try to call the api using the invoke command awsmobile cloud-api invoke ....
This looks like it's my screw-up - so sorry. I lint-ed the generated API output from the awsmobile
command and ran into the above errors. when I returned the file to the generated output, the errors went away. I'm testing some more, but obviously, something got messed up on my end. Sorry for the inquirery and thanks so much for the help!
I am getting this error in a browser:
after I alter the backend API file and
awsmobile publish
. I assume this may have something to do with a CORS hash? I can't find any documentation on how to update the backend and update the required CORS headers. Any help is much appreciated!