Select to view content in your preferred language

Error during service worker registration

1161
2
09-18-2024 12:14 AM
FieldSeekerAdministrator
New Contributor

init.js:1 Error during service worker registration: SecurityError: Failed to register a ServiceWorker for scope ('https://localhost:3001/') with script ('https://localhost:3001/service-worker.js'): An SSL certificate error occurred when fetching the script.
 I am creating a get-map-coordinates widget and when i run this widget i am getting above issue in the console.
Please help me on this
in the widget.tsx

import {React, type AllWidgetProps} from 'jimu-core';
import { JimuMapViewComponent, type JimuMapView } from 'jimu-arcgis';
import Point from '@arcgis/core/geometry/Point';
const { useState } = React;

const Widget =  (props: AllWidgetProps<any>) => {
    const [latitude, setLatitude] = useState<string>('');
    const [longitude, setLongitude] = useState<string>('');
    const activeViewChangeHandler = (jmv: JimuMapView) => {
        if(jmv) {
            jmv.view.on('pointer-move',(evt)=>{
                const point: Point = jmv.view.toMap({
                    x: evt.x,
                    y: evt.y
                })
                setLatitude(point.latitude.toFixed(3));
                setLongitude(point.longitude.toFixed(3))
            })
        }
    }
    return <div className='widget-starter jimu-widget'>
        {props.useMapWidgetIds && props.useMapWidgetIds.length === 1 && (
            <JimuMapViewComponent useMapWidgetId={props.useMapWidgetIds?.[0]} onActiveViewChange={activeViewChangeHandler} />
        )}
        <p>
            Lat/Lon: {latitude} {longitude}
        </p>
    </div>
}

export default Widget;
And in the Setting.tsx
import { React } from 'jimu-core';
import { type AllWidgetSettingProps } from 'jimu-for-builder';
import { MapWidgetSelector } from 'jimu-ui/advanced/setting-components';

const Setting = (props: AllWidgetSettingProps<any>) => {
    const onMapWidgetSelected = (useMapWidgetIds: string[]) => {
        props.onSettingChange({
            id: props.id,
            useMapWidgetIds: useMapWidgetIds
        })
   
    }
    return (
        <div className='widget-setting-demo'>
        <MapWidgetSelector useMapWidgetIds={props.useMapWidgetIds} onSelect={onMapWidgetSelected}/>
        This is your starter widget setting area!</div>
    )
}


export default Setting;
2 Replies
UofSC_KevinHaynes
Occasional Contributor

I am having this same problem. When I get into my experience dev on my localserver I can't add data to any widget. It says item unavailable and I'm getting this error in my browser. 

init.js:1 Error during service worker registration: SecurityError: Failed to register a ServiceWorker for scope ('https://localhost:3001/') with script ('https://localhost:3001/service-worker.js'): An SSL certificate error occurred when fetching the script.

0 Kudos
ÅsaBlomberg
Occasional Contributor

I get the same error when I try to use my custom made WebAppBuilder widget. The widget doesn't do anything yet since I'm just beginning to try this, but still it gives an error.

Error during service worker registration: SecurityError: Failed to register a ServiceWorker for scope ('https://localhost:3344/webappbuilder/apps/2/') with script ('https://localhost:3344/webappbuilder/apps/2/service-worker.js'): An SSL certificate error occurred when fetching the script.

0 Kudos