Skip to content

Commit cbe2618

Browse files
committed
Move manifest override into code-server
This way we will not have to patch it.
1 parent f2c096f commit cbe2618

File tree

1 file changed

+28
-1
lines changed

1 file changed

+28
-1
lines changed

src/node/routes/vscode.ts

+28-1
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ import { WebsocketRequest } from "../../../typings/pluginapi"
77
import { logError } from "../../common/util"
88
import { CodeArgs, toCodeArgs } from "../cli"
99
import { isDevMode } from "../constants"
10-
import { authenticated, ensureAuthenticated, redirect, self } from "../http"
10+
import { authenticated, ensureAuthenticated, redirect, replaceTemplates, self } from "../http"
1111
import { SocketProxyProvider } from "../socket"
1212
import { isFile, loadAMDModule } from "../util"
1313
import { Router as WsRouter } from "../wsRouter"
@@ -34,6 +34,32 @@ export class CodeServerRouteWrapper {
3434

3535
//#region Route Handlers
3636

37+
private manifest: express.Handler = async (req, res, next) => {
38+
res.writeHead(200, { "Content-Type": "application/manifest+json" })
39+
40+
return res.end(
41+
replaceTemplates(
42+
req,
43+
JSON.stringify(
44+
{
45+
name: "code-server",
46+
short_name: "code-server",
47+
start_url: ".",
48+
display: "fullscreen",
49+
description: "Run Code on a remote server.",
50+
icons: [192, 512].map((size) => ({
51+
src: `{{BASE}}/_static/src/browser/media/pwa-icon-${size}.png`,
52+
type: "image/png",
53+
sizes: `${size}x${size}`,
54+
})),
55+
},
56+
null,
57+
2,
58+
),
59+
),
60+
)
61+
}
62+
3763
private $root: express.Handler = async (req, res, next) => {
3864
const isAuthenticated = await authenticated(req)
3965
const NO_FOLDER_OR_WORKSPACE_QUERY = !req.query.folder && !req.query.workspace
@@ -141,6 +167,7 @@ export class CodeServerRouteWrapper {
141167

142168
constructor() {
143169
this.router.get("/", this.ensureCodeServerLoaded, this.$root)
170+
this.router.get(/manifest.json$/, this.manifest)
144171
this.router.all("*", ensureAuthenticated, this.ensureCodeServerLoaded, this.$proxyRequest)
145172
this._wsRouterWrapper.ws("/", ensureAuthenticated, this.ensureCodeServerLoaded, this.$proxyWebsocket)
146173
}

0 commit comments

Comments
 (0)