Skip to content

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

Open
@stanvanheumen

Description

@stanvanheumen

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');

Metadata

Metadata

Assignees

No one assigned

    Labels

    triage meI really want to be triaged.type: bugError or flaw in code with unintended results or allowing sub-optimal usage patterns.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions