Last active
December 31, 2015 04:29
-
-
Save icoloma/7934269 to your computer and use it in GitHub Desktop.
Test for using Google Maps with Content-Security-Policy
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var http = require('http') | |
// To use: execute "node maps-csp-test.js" and open a browser at localhost:8000 | |
// remember to restart the server after making any changes | |
var server = http.createServer( function(request, response) { | |
response.writeHead(200, { | |
'Content-Type': 'text/html; charset=UTF-8' | |
// This makes Google Maps work | |
, 'Content-Security-Policy': "script-src 'self' 'unsafe-inline' https://*.googleapis.com https://maps.gstatic.com 'unsafe-eval'" | |
// This makes Google Maps fail | |
//, 'Content-Security-Policy': "script-src 'self' 'unsafe-inline' https://*.googleapis.com https://maps.gstatic.com " | |
}); | |
response.write( | |
'<!doctype>' + | |
'<body>' + | |
'<p>Enter the name of a city' + | |
'<form><input id="autocomplete" type="text"></form>' + | |
'<script src="https://maps.googleapis.com/maps/api/js?sensor=false&libraries=places"></script>' + | |
'<script>new google.maps.places.Autocomplete(document.getElementById("autocomplete"));</script>' + | |
'</body>' | |
); | |
}); | |
// fire it up | |
console.log('Listening on port 8000'); | |
server.listen(8000); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
For the record, changing the last two scripts to these makes no difference: