Failed to Load URL

Seth 0 Reputation points
2023-02-06T21:26:30.3933333+00:00

Thank you for your help in advanced. I am creating a WebPart to deploy on SharePoint. I can run the local workbench and it works just fine. I bundled and packaged it to give to our IT department to add to the Apps Lists so I can add it to my SharePoint. However, I get the error below. I know it want to run from the local host. Where or how do I change the URL it is running from? Is this something the "gulp bundle" or "gulp package-ship" is supposed to do?

SPLoaderError.loadComponentError]:
Failed to load component "CUID" (TrainingDashboardWebPart). Original error: Failed to load URL 'https://localhost:4321/dist/TrainingDashboardWebPartStrings_en-us.js' for resource 'TrainingDashboardWebPartStrings' in component 'CUID' (TrainingDashboardWebPart). There was a network problem. Make sure that you are running 'gulp serve' and you have run 'gulp trust-dev-cert'.

Microsoft 365 and Office SharePoint Development
0 comments No comments
{count} votes

1 answer

Sort by: Most helpful
  1. RaytheonXie_MSFT 40,471 Reputation points Microsoft External Staff
    2023-02-07T02:15:11.8+00:00

    Hi @Seth

    When you deploy the package, please check if it gets content from localhost:

    enter image description here

    You can try following command to fix

    gulp clean
    gulp build
    gulp bundle --ship
    gulp package-solution --ship
    
    

    You can enable Office 365 CDN and host the webpart on CDN

    Host your client-side web part from Microsoft 365 CDN (Hello World part 4)


    If the answer is helpful, please click "Accept Answer" and kindly upvote it. If you have extra questions about this answer, please click "Comment".

    Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.


Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.