Skip to content

Debugging SPFx Solutions in Github Codespaces #7720

@shurick81

Description

@shurick81

What type of issue is this?

Question

What SharePoint development model, framework, SDK or API is this about?

💥 SharePoint Framework

Target SharePoint environment

SharePoint Online

What browser(s) / client(s) have you tested

  • 💥 Internet Explorer
  • 💥 Microsoft Edge
  • 💥 Google Chrome
  • 💥 FireFox
  • 💥 Safari
  • mobile (iOS/iPadOS)
  • mobile (Android)
  • not applicable
  • other (enter in the "Additional environment details" area below)

Additional environment details

  • SPFx 1.13.1
  • Node.js 14

Issue description

Would it be possible to debug SPFx solutions using Github workspaces?

When I just try to run the solution as is, I get an error in the hosted workbench:

https://steria.sharepoint.com/_layouts/15/workbench.aspx?debug=true&noredir=true&debugManifestsFile=https://shurick81-alexsapozhkov-codespaces-demo-00-77p5r5x73xrpw-4321.githubpreview.dev/temp/manifests.js

image

I try to dig deeper and checking https://shurick81-alexsapozhkov-codespaces-demo-00-77p5r5x73xrpw-4321.githubpreview.dev/temp/manifests.js in the browser, I'm getting a Bad Gateway error:

image

Then I try to fix the latter one and do the following changes (that helps for running SPFx gulp serve in containers: https://github.com/pnp/docker-spfx#known-issues):

  1. Modify node_modules\@microsoft\spfx-heft-plugins\lib\plugins\webpackConfigurationPlugin\WebpackConfigurationGenerator.js:393
const debugBaseUrl = `${serveConfig.https ? 'https' : 'http'}://${serveConfig.hostname || 'localhost'}:${serveConfig.port || 4321}/${distFolderName}/`;

to:

const debugBaseUrl = `${serveConfig.https ? 'https' : 'http'}://localhost:${serveConfig.port || 4321}/${distFolderName}/`;
  1. map the workbench to 0.0.0.0, by modifying the ./config/serve.json file in your SharePoint Framework project to:
{
  "$schema": "https://developer.microsoft.com/json-schemas/core-build/serve.schema.json",
  "port": 4321,
  "hostname": "0.0.0.0",
  "https": true,
  "initialPage": "https://enter-your-SharePoint-site/_layouts/workbench.aspx"
}

I get the response when I request js file then:
image

However, when I try to run the hosted workbench, I get new issues:

image

When I look into developer tools in the browser, I can see that the browser is getting proper response from https://shurick81-alexsapozhkov-codespaces-demo-00-77p5r5x73xrpw-4321.githubpreview.dev/temp/manifests.js but then it is trying to access resources from https://localhost:4321/temp/manifests.js and of course fails:

image

I might guess that the reason is that the file https://shurick81-alexsapozhkov-codespaces-demo-00-77p5r5x73xrpw-4321.githubpreview.dev/temp/manifests.js actually contains a lot of references on the localhost:

image

Metadata

Metadata

Assignees

No one assigned

    Labels

    area:spfxCategory: SharePoint Framework (not extensions related)type:questionQuestion... if answered, will be tagged as such.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions