Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Issue with the "nonce" parameter in the constructor #955

Open
stanvanheumen opened this issue Mar 21, 2025 · 0 comments
Open

Issue with the "nonce" parameter in the constructor #955

stanvanheumen opened this issue Mar 21, 2025 · 0 comments
Labels
triage me I really want to be triaged. type: bug Error or flaw in code with unintended results or allowing sub-optimal usage patterns.

Comments

@stanvanheumen
Copy link

I've noticed that my nonce is not being applied (used Chrome v134.0.6998.89 to test this).

When using the Dynamic Library Import script on https://developers.google.com/maps/documentation/javascript/load-maps-js-api or using the js-api-loader library I noticed that my supplied nonce is not being applied to the generated script.

When checking out the import script and code of the js-api-loader it seems that that nonce is being set by using a .nonce="" syntax. This does not work for me. When adjusting the script and using .setAttribute("nonce", "") it does work tho. What's the reason behind this?

Environment details

  1. Using the "places" API only; see code example;
  2. Operating system: Mac OSX 15.3.2
  3. Chrome v134.0.6998.89
  4. Library version: v1.16.9

Steps to reproduce

  1. Create a new project and add the js-api-loader;
  2. Setup the loader and try to import the "places" library;
  3. Add a nonce to the Loader constructor params;
  4. Check if the generated script contain a nonce; It doesn't for me.

Code example

import {Loader} from '@googlemaps/js-api-loader';

 const loader = new Loader({
    apiKey: "<KEY>",
    nonce: "<NONCE>",
    version: 'weekly',
    libraries: ['places']
});

const {Autocomplete} = await loader.importLibrary('places');
@stanvanheumen stanvanheumen added triage me I really want to be triaged. type: bug Error or flaw in code with unintended results or allowing sub-optimal usage patterns. labels Mar 21, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
triage me I really want to be triaged. type: bug Error or flaw in code with unintended results or allowing sub-optimal usage patterns.
Projects
None yet
Development

No branches or pull requests

1 participant