0

I've made a custom Webform component, working well so far. A javascript library is attached to this component.

$elements['#attached']['library'][] = 'my_module/my_lib';

My client tried to add custom css and js but here /admin/webform/manage/webform_id/settings/assets for some reason , he has this error :

Resource from « https://xyz.com/webform/css/webform_id?s4muhb » was blocked because of type MIME (« text/html ») incorrect (X-Content-Type-Options: nosniff).

After digging and testing, it seems like this part of the code is generating the error:

$route = Url::fromRoute('my_module.custom_ajax_route');
$elements['#attached']['drupalSettings']['my_module']['url'] = $route->toString();

If instead of $route->toString() I set the route '/theroute' and clear the cache, the custom css is working fine.

I'm using Drupal 10.1.4, apache and webform 6.2


EDIT

FYO, my function is a generic static function that generate field

public static function generateMyFields() ...

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Browse other questions tagged or ask your own question.