tinylicious服务器可以在3000以外的端口启动吗?我尝试过像"PORT=4100 tinylicious“这样的东西,我可以看到终端日志说:
@federation/shell-app: [1] info: Listening on port 4100 {"label":"winston","timestamp":"2021-03-08T19:23:37.861Z"}但后来它在我的代码中失败了,表明服务调用出现了问题:
main.js:15815 ERROR TypeError: Cannot read property 'shapeClicked' of undefined
at Layer.onClick [as zzClickFunc] (collabmap.component.js:45)
at JS:24817
at Array.<anonymous> (JS:8190)
at window.<computed> (JS:1111)
at Object.<anonymous> (JS:51778)
at j (JS:51777)事实上,Network选项卡显示它仍在通过3000发布:
Request URL: http://localhost:3000/documents/tinylicious
Referrer Policy: strict-origin-when-cross-origin我知道tinylicious不是完整的Fluid服务器,它只是为了测试目的,所以它可能已经硬连到3000,但也许有人知道如何在不同的端口上启动它。
发布于 2021-03-13 08:52:44
Tinylicious服务器端口绝对是可配置的。
如果你覆盖了他们的库,那么你将能够使用任何可能的端口运行你的应用程序。
你一定注意到了这个函数:
getTinyliciousContainer();在它的库get-tinylicious container和tinylicious driver中,你会在tinylicious driver: insecureTinyliciousUrlResolver.ts中看到它们的一个文件,其中每个该死的host:port都被硬编码为localhost:3000。
因此,只需从他们的getTinyliciousContainer和tinylicious驱动程序中复制他们的代码,并制作您自己版本的getTinyliciousContainer。将来,您需要复制这些代码来配置Routerlicious,因为Tinylicious是非常轻量级的,建议仅用于测试目的。您需要在@fluidframework/tinylicious driver中修改的文件是insecureTinyliciousUrlResolver.ts:
export class InsecureTinyliciousUrlResolver implements IUrlResolver {
public async resolve(request: IRequest): Promise<IResolvedUrl> {
const url = request.url.replace(`http://${serviceHostName}:${servicePort}/`,"");
const documentId = url.split("/")[0];
const encodedDocId = encodeURIComponent(documentId);
const documentRelativePath = url.slice(documentId.length);
const serviceHostName = "YOUR-PREFERRED-HOST-NAME";
const servicePort = "YOUR-PREFERRED-PORT";
const documentUrl = `fluid://${serviceHostName}:${servicePort}/tinylicious/${encodedDocId}${documentRelativePath}`;
const deltaStorageUrl = `http://${serviceHostName}:${servicePort}/deltas/tinylicious/${encodedDocId}`;
const storageUrl = `http://${serviceHostName}:${servicePort}/repos/tinylicious`;
const response: IFluidResolvedUrl = {
endpoints: {
deltaStorageUrl,
ordererUrl: `http://${serviceHostName}:${servicePort}`,
storageUrl,
},
tokens: { jwt: this.auth(documentId) },
type: "fluid",
url: documentUrl,
};
return response;
}
public async getAbsoluteUrl(resolvedUrl: IFluidResolvedUrl, relativeUrl: string): Promise<string> {
const documentId = decodeURIComponent(resolvedUrl.url.replace(`fluid://${serviceHostName}:${servicePort}/tinylicious/`, ""));
/*
* The detached container flow will ultimately call getAbsoluteUrl() with the resolved.url produced by
* resolve(). The container expects getAbsoluteUrl's return value to be a URL that can then be roundtripped
* back through resolve() again, and get the same result again. So we'll return a "URL" with the same format
* described above.
*/
return `${documentId}/${relativeUrl}`;
}
private auth(documentId: string) {
const claims: ITokenClaims = {
documentId,
scopes: ["doc:read", "doc:write", "summary:write"],
tenantId: "tinylicious",
user: { id: uuid() },
// @ts-ignore
iat: Math.round(new Date().getTime() / 1000),
exp: Math.round(new Date().getTime() / 1000) + 60 * 60, // 1 hour expiration
ver: "1.0",
};
const utf8Key = { utf8: "12345" };
return jsrsasign.jws.JWS.sign(null, JSON.stringify({ alg:"HS256", typ: "JWT" }), claims, utf8Key);
}
}
export const createTinyliciousCreateNewRequest =
(documentId: string): IRequest=> (
{
url: documentId,
headers:{
createNew: true,
},
}
);然后,您只需独立运行此React应用程序,而不是并发运行,并且没有内置的Tinylicious服务器。
转到他们的GitHub,在FluidFramework/服务器资源库中克隆他们的Tinylicious,然后在你想要的任何端口上运行它。
现在,您可以在任何主机上、任何您想要的端口上运行Tinylicious。
发布于 2021-07-10 02:00:23
Tinylicious端口现在是可配置的。有关更多细节,请参阅https://github.com/microsoft/FluidFramework/issues/5415
https://stackoverflow.com/questions/66536190
复制相似问题