Quantcast
Channel: Active questions tagged amazon-ec2 - Stack Overflow
Viewing all articles
Browse latest Browse all 29543

Getting CORS error using Express + AWS, created API Gateway process/method, but still won't work

$
0
0

I've got an express server that I've uploaded to an ec2. Prior, I've verified that it works on my PC using localhost.

I've added cors using node, I've created an API Gateway for post, still getting the error: Cross-Origin Request Blocked: The Same Origin Policy disallows reading the remote resource at /register. (Reason: CORS header ‘Access-Control-Allow-Origin’ missing).

Where do I need to look? I didn't make any changes to my route after creating the API Gateway, so I'm not sure if I need to do anything else. All I did was create a /register resource with a Post method, and enabled CORS on the resource.

In my express server, I'm using the cors module:

const cors = require('cors')
app.use(cors());

For my first route in aws, I have this route in the express server:

router.post('/register', (req, res) => {

In my AWS API Gateway, I created the route: enter image description here

In my firefox console, if I click on the link in the messages, I get this: enter image description here


Viewing all articles
Browse latest Browse all 29543

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>