@@ -57,7 +57,7 @@ Default to be \`[server.protocol]://[server.host][:server.port]\` if not specifi
|
|||||||
env: ['AFFINE_SERVER_PORT', 'integer'],
|
env: ['AFFINE_SERVER_PORT', 'integer'],
|
||||||
},
|
},
|
||||||
path: {
|
path: {
|
||||||
desc: 'Subpath where the server get deployed if there is.',
|
desc: 'Subpath where the server get deployed if there is one.(e.g. /affine)',
|
||||||
default: '',
|
default: '',
|
||||||
env: 'AFFINE_SERVER_SUB_PATH',
|
env: 'AFFINE_SERVER_SUB_PATH',
|
||||||
},
|
},
|
||||||
|
|||||||
@@ -5,7 +5,7 @@ import { Controller, Get, Logger, Req, Res } from '@nestjs/common';
|
|||||||
import type { Request, Response } from 'express';
|
import type { Request, Response } from 'express';
|
||||||
import isMobile from 'is-mobile';
|
import isMobile from 'is-mobile';
|
||||||
|
|
||||||
import { metrics } from '../../base';
|
import { Config, metrics } from '../../base';
|
||||||
import { Models } from '../../models';
|
import { Models } from '../../models';
|
||||||
import { htmlSanitize } from '../../native';
|
import { htmlSanitize } from '../../native';
|
||||||
import { Public } from '../auth';
|
import { Public } from '../auth';
|
||||||
@@ -51,7 +51,8 @@ export class DocRendererController {
|
|||||||
|
|
||||||
constructor(
|
constructor(
|
||||||
private readonly doc: DocReader,
|
private readonly doc: DocReader,
|
||||||
private readonly models: Models
|
private readonly models: Models,
|
||||||
|
private readonly config: Config
|
||||||
) {
|
) {
|
||||||
this.webAssets = this.readHtmlAssets(join(env.projectRoot, 'static'));
|
this.webAssets = this.readHtmlAssets(join(env.projectRoot, 'static'));
|
||||||
this.mobileAssets = this.readHtmlAssets(
|
this.mobileAssets = this.readHtmlAssets(
|
||||||
@@ -140,6 +141,7 @@ export class DocRendererController {
|
|||||||
// TODO(@forehalo): how can we enable the type reference to @affine/env
|
// TODO(@forehalo): how can we enable the type reference to @affine/env
|
||||||
const envMeta: Record<string, any> = {
|
const envMeta: Record<string, any> = {
|
||||||
publicPath: assets.publicPath,
|
publicPath: assets.publicPath,
|
||||||
|
subPath: this.config.server.path,
|
||||||
renderer: 'ssr',
|
renderer: 'ssr',
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
4
packages/common/env/src/global.ts
vendored
4
packages/common/env/src/global.ts
vendored
@@ -16,8 +16,10 @@ export function setupGlobal() {
|
|||||||
isPwa: false,
|
isPwa: false,
|
||||||
isMobile: false,
|
isMobile: false,
|
||||||
isSelfHosted: false,
|
isSelfHosted: false,
|
||||||
|
// publicPath is the root of assets files
|
||||||
publicPath: '/',
|
publicPath: '/',
|
||||||
workerPath: '/js/',
|
// subPath is the path to access the affine service
|
||||||
|
subPath: '',
|
||||||
};
|
};
|
||||||
|
|
||||||
if (globalThis.navigator) {
|
if (globalThis.navigator) {
|
||||||
|
|||||||
4
packages/common/env/src/worker.ts
vendored
4
packages/common/env/src/worker.ts
vendored
@@ -1,5 +1,7 @@
|
|||||||
export function getWorkerUrl(name: string) {
|
export function getWorkerUrl(name: string) {
|
||||||
return (
|
return (
|
||||||
environment.workerPath + `${name}-${BUILD_CONFIG.appVersion}.worker.js`
|
environment.publicPath +
|
||||||
|
'js/' +
|
||||||
|
`${name}-${BUILD_CONFIG.appVersion}.worker.js`
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -188,6 +188,7 @@ const createBrowserRouter = wrapCreateBrowserRouterV6(
|
|||||||
export const router = (
|
export const router = (
|
||||||
window.SENTRY_RELEASE ? createBrowserRouter : reactRouterCreateBrowserRouter
|
window.SENTRY_RELEASE ? createBrowserRouter : reactRouterCreateBrowserRouter
|
||||||
)(topLevelRoutes, {
|
)(topLevelRoutes, {
|
||||||
|
basename: environment.subPath,
|
||||||
future: {
|
future: {
|
||||||
v7_normalizeFormMethod: true,
|
v7_normalizeFormMethod: true,
|
||||||
},
|
},
|
||||||
|
|||||||
2
tools/@types/env/__all.d.ts
vendored
2
tools/@types/env/__all.d.ts
vendored
@@ -37,7 +37,7 @@ declare type Environment = {
|
|||||||
|
|
||||||
// runtime configs
|
// runtime configs
|
||||||
publicPath: string;
|
publicPath: string;
|
||||||
workerPath: string
|
subPath: string;
|
||||||
};
|
};
|
||||||
|
|
||||||
var process: {
|
var process: {
|
||||||
|
|||||||
Reference in New Issue
Block a user