Jason CV Helper: Local Testing & CORS Tips

Why CORS Matters

APIs enforce Cross-Origin Resource Sharing (CORS) to prevent unauthorized requests. If you try to query an AWS Lambda API from your local machine (localhost) or a live website, the API must allow your origin.

Setting the Origin in AWS API Gateway / Lambda

In your Lambda function, make sure your HTTP response headers include:

{
  "statusCode": 200,
  "headers": {
    "Access-Control-Allow-Origin": "https://jasoncv.click, http://localhost:8000",
    "Access-Control-Allow-Methods": "POST,GET,OPTIONS",
    "Access-Control-Allow-Headers": "Content-Type"
  },
  "body": "...your response..."
}

This allows your API to respond both from your live website and from a local server for testing.

Testing Locally with Python

To serve your HTML locally for testing, navigate to your project folder and run:

python -m http.server 8000

Then open your browser at http://localhost:8000/yourfile.html.

This simulates a live environment and allows your Lambda/API CORS rules to be tested with the local origin.

Summary / Tips