fix(preview): only show browser-ready local servers #6021
Mergedchrisdeeming(GitHub profile, opens in a new tab)merged 2 commits into
main fromrefs/pull/6021/headmerged by maria-rcks View on GitHubgithub-actions[bot](GitHub profile, opens in a new tab) added labelssize:L
- apps/server/src/preview/PortScanner.ts lines 250 to 254OutdatedResolvedby macroscopeapp[bot](GitHub profile, opens in a new tab)@@ -221,3 +242,13 @@221242 }));222243 });223244245+ const probeWebServer = Effect.fn("PortDiscovery.probeWebServer")(function* (246+ server: DiscoveredLocalServer,247+ ) {248+ for (const protocol of ["http", "https"] as const) {249+ const url = `${protocol}://${server.host}:${server.port}`;250+ const responseUrl = yield* httpClient.get(url).pipe(251+ Effect.map((response) => {252+ const location = response.headers.location?.trim();253+ if (response.status >= 300 && response.status < 400 && location) return url;254+ if (response.status < 200 || response.status >= 300) return null;
- apps/server/src/preview/PortScanner.ts line 272OutdatedResolvedby chrisdeeming(GitHub profile, opens in a new tab)@@ -223,0 +252,21 @@252+ const location = response.headers.location?.trim();253+ if (response.status >= 300 && response.status < 400 && location) return url;254+ if (response.status < 200 || response.status >= 300) return null;255+ const contentType = response.headers["content-type"]256+ ?.split(";", 1)[0]257+ ?.trim()258+ .toLowerCase();259+ return contentType === "text/html" || contentType === "application/xhtml+xml"260+ ? url261+ : null;262+ }),263+ Effect.scoped,264+ Effect.timeoutOption(WEB_PROBE_TIMEOUT),265+ Effect.map(Option.getOrNull),266+ Effect.orElseSucceed(() => null),267+ Effect.provideService(FetchHttpClient.RequestInit, { redirect: "manual" }),268+ );269+ if (responseUrl !== null) return responseUrl;270+ }271+ return null;272+ });
github-actions[bot](GitHub profile, opens in a new tab) added labelsvouch:trusted
github-actions[bot](GitHub profile, opens in a new tab) removed labelssize:L
github-actions[bot](GitHub profile, opens in a new tab) added labelssize:XL
- apps/server/src/preview/PortScanner.ts line 378Resolvedby cursor[bot](GitHub profile, opens in a new tab)@@ -223,0 +354,21 @@354+ const configuredResources = new Set<string>();355+356+ for (const raw of configuredUrls) {357+ const url = new URL(raw);358+ const port = urlPort(url);359+ const key = localServerKey(url.hostname, port);360+ const resourceKey = webProbeCacheKey(raw);361+ if (configuredResources.has(resourceKey)) continue;362+ configuredResources.add(resourceKey);363+ groups.push({364+ server: serversByKey.get(key) ?? {365+ host: url.hostname,366+ port,367+ url: raw,368+ processName: null,369+ pid: null,370+ terminal: null,371+ },372+ urls: [raw],373+ configuredKey: resourceKey,374+ });
t3-code-bot[bot](GitHub profile, opens in a new tab) approved these changes
maria-rcks merged this9fd788b
maria-rcks closed this
Sign in to join this conversation.


Important
Review skipped#
Auto reviews are disabled on this repository. Please check the settings in the CodeRabbit UI or the
.coderabbit.yamlfile in this repository. To trigger a single review, invoke the@coderabbitai reviewcommand.⚙️ Run configuration
Configuration used: Repository UI
Review profile: CHILL
Plan: Pro Plus
Run ID:
177566ed-53c6-4a88-94d9-402caac3761eYou can disable this status message by setting the
reviews.review_statustofalsein the CodeRabbit configuration file.Use the checkbox below for a quick retry:
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.
❤️ Share