Harbor 前端开发
如果您已经有一个 Harbor 后端环境,您可以使用以下配置构建一个前端开发环境。
-
打开终端并运行以下命令,将 “proxy.config.mjs.temp” 文件复制到 “proxy.config.mjs”。
cd harbor/src/portal cp proxy.config.mjs.temp proxy.config.mjs
注意: 您应该指定一个可用的 Harbor 主机名。如果您在公司代理后面工作,您可以指定代理。
import HttpsProxyAgent from 'https-proxy-agent';
// Define the proxy configuration
const HarborProxyConfig = [
{
"context": [
"/api",
"/c",
"/i18n",
"/chartrepo",
"/LICENSE",
"/swagger.json",
"/devcenter-api-2.0",
"/swagger-ui.bundle.js"
],
"target": "${A Harbor server}",
"secure": false,
"changeOrigin": true,
"logLevel": "debug"
}
];
// Define if you use agent
const useAgent = false;
// Specify an agent server, if empty, will read it from environment variable http_proxy or HTTP_PROXY
const specifiedAgentServer = "${An agent server}";
function setupForCorporateProxy(proxyConfig) {
if (useAgent) {
const agentServer = process.env.http_proxy || process.env.HTTP_PROXY || specifiedAgentServer;
if (agentServer) {
const agent = new HttpsProxyAgent(agentServer);
console.log('Using corporate agent server: ' + agentServer);
proxyConfig.forEach(function (entry) {
entry.agent = agent;
});
}
}
return proxyConfig;
}
export default setupForCorporateProxy(HarborProxyConfig);
-
安装 npm 包和第三方依赖。
npm install
-
执行以下命令,在本地启动 Harbor。
npm run start
-
然后您可以通过地址访问 Harbor:https://localhost:4200。
贡献