infosec.mozilla.org | Guidelines , principles published on https | Authorization library
kandi X-RAY | infosec.mozilla.org Summary
kandi X-RAY | infosec.mozilla.org Summary
Guidelines, principles published on
Support
Quality
Security
License
Reuse
Top functions reviewed by kandi - BETA
Currently covering the most popular Java, JavaScript and Python libraries. See a Sample of infosec.mozilla.org
infosec.mozilla.org Key Features
infosec.mozilla.org Examples and Code Snippets
Community Discussions
Trending Discussions on infosec.mozilla.org
QUESTION
I'm hosting a static website on AWS (stored in S3, with CloudFront + Lambda@Edge). I've added some basic javascript to respond to button clicks (since I will be sending the form data to AWS API Gateway using AJAX, etc), but the javascript only seems to work locally, not online.
To be specific, if you go to my website and click on the button, nothing happens, regardless of what you enter in the text field. But if you "View page source" and save it locally, it will respond as expected (alerts pop-up and text field changes color depending on whether or not id is valid).
I've used jslint and regex101 to check and clean my code. I've removed all CSS and unrelated content. I've also reproduced the problem on several devices and browsers (always works fine locally). I'm pretty new to AWS and Javascript, so maybe it's something basic, but I've hit a roadblock after several days. Any help would be much appreciated!
I'm reproducing the html below (for posterity):
...ANSWER
Answered 2021-Mar-25 at 05:54Well, a few key lessons I learned here:
- Best way to debug (non-responsive) JavaScript is browser's More tools > Developer Tools > Console tab. Without this, I was flying blind.
- The problem was not with the JavaScript, but rather with the security headers I was adding. I had followed this AWS article without a deep understanding of the directives, and they blocked my JavaScript.
- Inline JavaScript is bad! Make sure you put all your scripts into a separate file. Maybe this is obvious to you, but I had to read this article to understand why. Plus I have seen many Stack Overflow questions with inline JavaScript, so I question if this is really well known...
- Use the Mozilla Observatory and Google's CSP Evaluator to check and improve your website's security.
In the end, I used the following Content-Security-Policy headers:
Community Discussions, Code Snippets contain sources that include Stack Exchange Network
Vulnerabilities
No vulnerabilities reported
Install infosec.mozilla.org
The site is rendered by Jekyll.
The font (ZillaLab) and logos are from the Mozilla Design Language.
https://infosec.mozilla.org is fronted by AWS CloudFront and utilizes a Lambda@Edge function, that are described in the aws directory of this repository.
Support
Reuse Trending Solutions
Find, review, and download reusable Libraries, Code Snippets, Cloud APIs from over 650 million Knowledge Items
Find more librariesStay Updated
Subscribe to our newsletter for trending solutions and developer bootcamps
Share this Page