Skip to content

Commit 3cf94bb

Browse files
Fixes #5335 where PWAs with redirects could cause packaging issues
1 parent aa7bb14 commit 3cf94bb

File tree

3 files changed

+61
-59
lines changed

3 files changed

+61
-59
lines changed

apps/pwabuilder-microsoft-store/Services/PwaBuilderWrapper.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -116,7 +116,7 @@ private ProcessException CreatePwaBuilderCliError(
116116
WebAppManifestContext webManifest)
117117
{
118118
var pwabuilderCLIArgs = CreateCommandLineArgs(options, appImages, webManifest, actionFiles, outputDirectory);
119-
var formattedMessage = string.Join(Environment.NewLine + Environment.NewLine, message, $"Output directory: {outputDirectory}", $"Standard output: {standardOutput}", $"Standard error: {standardErrorOutput}");
119+
var formattedMessage = string.Join(Environment.NewLine + Environment.NewLine, message, $"Output directory: {outputDirectory}", $"Standard output: {standardOutput}", $"Standard error: {standardErrorOutput}", $"CLI args: {pwabuilderCLIArgs}");
120120
var toolFailedError = new ProcessException(formattedMessage, innerException, standardOutput, standardErrorOutput);
121121
toolFailedError.Data.Add("StandardOutput", standardOutput);
122122
toolFailedError.Data.Add("StandardError", standardErrorOutput);

apps/pwabuilder-microsoft-store/Services/WindowsAppPackageCreator.cs

Lines changed: 36 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -67,13 +67,14 @@ public async Task<WindowsAppPackageResult> CreateAppPackageAsync(WindowsAppPacka
6767
{
6868
ValidateOptions(options);
6969

70+
// COMMENTED OUT 2/25/2026 - This code had unintended consequences. For example, this code would detect https://app.eyegifs.com redirects to https://app.eyegifs.com/account/login. But if the user is logged in, we want the PWA to keep the original url and not redirect to login.
7071
// Check for redirects.
71-
var redirectUri = await TryCheckForRedirect(options.Url);
72-
if (redirectUri != null)
73-
{
74-
logger.LogInformation("Detected redirect for {url}, redirecting to {target}. Will use the redirect target for packaging.", options.Url, redirectUri);
75-
options.Url = redirectUri;
76-
}
72+
// var redirectUri = await TryCheckForRedirect(options.Url);
73+
// if (redirectUri != null)
74+
// {
75+
// logger.LogInformation("Detected redirect for {url}, redirecting to {target}. Will use the redirect target for packaging.", options.Url, redirectUri);
76+
// options.Url = redirectUri;
77+
// }
7778

7879
var packageType = options.Publisher == null || options.Publisher.CommonName == devPackagePublisherCommonName ?
7980
WindowsPackageType.DeveloperPackage : WindowsPackageType.StorePackage;
@@ -126,34 +127,35 @@ private void ValidateOptions(WindowsAppPackageOptions options)
126127
}
127128
}
128129

129-
/// <summary>
130-
/// Checks if the specified URL results in a redirect (301 or 307). If so, returns the Location target of the redirect.
131-
/// </summary>
132-
/// <remarks>
133-
/// This fixes a bug (https://github.com/pwa-builder/PWABuilder/issues/4956) where if the user packages a URL that causes a redirect, Edge doesn't properly handle the installed PWA.
134-
/// We fix the bug by checking if there's a redirect for the URL and if so, returns the redirect target URL.
135-
/// An example as of June 2025 is https://microsoftedge.github.io/Demos/wami, which redirects to https://microsoftedge.github.io/Demos/wami/ (notice the ending slash).
136-
/// </remarks>
137-
/// <param name="options"></param>
138-
/// <returns>The redirect target URL if there is one.</returns>
139-
private async Task<Uri?> TryCheckForRedirect(Uri uri)
140-
{
141-
try
142-
{
143-
var response = await this.httpNoAutoRedirect.GetAsync(uri);
144-
var isRedirect = (int)response.StatusCode >= 300 && (int)response.StatusCode < 400;
145-
if (isRedirect && response.Headers.Location != null)
146-
{
147-
return response.Headers.Location;
148-
}
149-
}
150-
catch (Exception httpError)
151-
{
152-
logger.LogWarning(httpError, "Unable to check the URL for redirect due to HTTP error.");
153-
}
154-
155-
return null;
156-
}
130+
// COMMENTED OUT: 2/25/2026 - This code had unintended consequences. For example, this code would detect https://app.eyegifs.com redirects to https://app.eyegifs.com/account/login. But if the user is logged in, we want the PWA to keep the original url and not redirect to login.
131+
// /// <summary>
132+
// /// Checks if the specified URL results in a redirect (301 or 307). If so, returns the Location target of the redirect.
133+
// /// </summary>
134+
// /// <remarks>
135+
// /// This fixes a bug (https://github.com/pwa-builder/PWABuilder/issues/4956) where if the user packages a URL that causes a redirect, Edge doesn't properly handle the installed PWA.
136+
// /// We fix the bug by checking if there's a redirect for the URL and if so, returns the redirect target URL.
137+
// /// An example as of June 2025 is https://microsoftedge.github.io/Demos/wami, which redirects to https://microsoftedge.github.io/Demos/wami/ (notice the ending slash).
138+
// /// </remarks>
139+
// /// <param name="options"></param>
140+
// /// <returns>The redirect target URL if there is one.</returns>
141+
// private async Task<Uri?> TryCheckForRedirect(Uri uri)
142+
// {
143+
// try
144+
// {
145+
// var response = await this.httpNoAutoRedirect.GetAsync(uri);
146+
// var isRedirect = (int)response.StatusCode >= 300 && (int)response.StatusCode < 400;
147+
// if (isRedirect && response.Headers.Location != null)
148+
// {
149+
// return new Uri(uri, response.Headers.Location);
150+
// }
151+
// }
152+
// catch (Exception httpError)
153+
// {
154+
// logger.LogWarning(httpError, "Unable to check the URL for redirect due to HTTP error.");
155+
// }
156+
157+
// return null;
158+
// }
157159

158160
private async Task<MsixResult> GenerateMsix(WindowsAppPackageOptions options, CancellationToken cancelToken)
159161
{
Lines changed: 24 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -1,26 +1,26 @@
11
{
2-
"Logging": {
3-
"LogLevel": {
4-
"Default": "Information",
5-
"Microsoft": "Warning",
6-
"Microsoft.Hosting.Lifetime": "Information"
7-
}
8-
},
9-
"AppSettings": {
10-
"PwaBuilderPath": "bin\\Debug\\net10.0\\Resources\\cli\\pwabuilder\\pwa_builder.exe",
11-
"PwaInstallerPath": "bin\\Debug\\net10.0\\Resources\\cli\\pwainstaller\\pwainstaller.exe",
12-
"InstallScriptPath": "bin\\Debug\\net10.0\\Resources\\install.ps1",
13-
"ClassicWindowsAppPackagePath": "bin\\Debug\\net10.0\\Resources\\ClassicWindowsAppPackage.appx",
14-
"SpartanWindowsAppPackagePath": "bin\\Debug\\net10.0\\Resources\\SpartanWindowsAppPackage.appx",
15-
"SpartanInstallScriptPath": "bin\\Debug\\net10.0\\Resources\\install-edgehtml.ps1",
16-
"SpartanReadmePath": "bin\\Debug\\net10.0\\Resources\\next-steps-edgehtml.html",
17-
"StoreSupportedLanguagesPath": "bin\\Debug\\net10.0\\Resources\\store-supported-languages.txt",
18-
"PriPath": "bin\\Debug\\net10.0\\Resources\\resources.pri",
19-
"ReadmePath": "bin\\Debug\\net10.0\\Resources\\next-steps.html",
20-
"OutputDirectory": "%temp%",
21-
"WindowsSdkDirectory": "E:\\sdks\\windows-sdk\\bin\\10.0.26100.0\\x64",
22-
"UrlLoggerService": "",
23-
"ImageGeneratorApiUrl": "https://localhost:7217/api/images/generateStoreImages",
24-
"ApplicationInsightsConnectionString": ""
2+
"Logging": {
3+
"LogLevel": {
4+
"Default": "Information",
5+
"Microsoft": "Warning",
6+
"Microsoft.Hosting.Lifetime": "Information"
257
}
26-
}
8+
},
9+
"AppSettings": {
10+
"PwaBuilderPath": "bin\\Debug\\net10.0\\Resources\\cli\\pwabuilder\\pwa_builder.exe",
11+
"PwaInstallerPath": "bin\\Debug\\net10.0\\Resources\\cli\\pwainstaller\\pwainstaller.exe",
12+
"InstallScriptPath": "bin\\Debug\\net10.0\\Resources\\install.ps1",
13+
"ClassicWindowsAppPackagePath": "bin\\Debug\\net10.0\\Resources\\ClassicWindowsAppPackage.appx",
14+
"SpartanWindowsAppPackagePath": "bin\\Debug\\net10.0\\Resources\\SpartanWindowsAppPackage.appx",
15+
"SpartanInstallScriptPath": "bin\\Debug\\net10.0\\Resources\\install-edgehtml.ps1",
16+
"SpartanReadmePath": "bin\\Debug\\net10.0\\Resources\\next-steps-edgehtml.html",
17+
"StoreSupportedLanguagesPath": "bin\\Debug\\net10.0\\Resources\\store-supported-languages.txt",
18+
"PriPath": "bin\\Debug\\net10.0\\Resources\\resources.pri",
19+
"ReadmePath": "bin\\Debug\\net10.0\\Resources\\next-steps.html",
20+
"OutputDirectory": "%temp%",
21+
"WindowsSdkDirectory": "C:\\Program Files (x86)\\Windows Kits\\10\\bin\\10.0.26100.0\\x64",
22+
"UrlLoggerService": "",
23+
"ImageGeneratorApiUrl": "https://pwabuilder.com/api/images/generateStoreImages",
24+
"ApplicationInsightsConnectionString": ""
25+
}
26+
}

0 commit comments

Comments
 (0)