{"id":19751142,"url":"https://github.com/mipengine/mip-cli-plugin-sf","last_synced_at":"2026-05-11T01:39:23.408Z","repository":{"id":81009032,"uuid":"147647061","full_name":"mipengine/mip-cli-plugin-sf","owner":"mipengine","description":"Enable offline SF","archived":false,"fork":false,"pushed_at":"2019-02-15T08:47:10.000Z","size":13,"stargazers_count":0,"open_issues_count":0,"forks_count":1,"subscribers_count":14,"default_branch":"master","last_synced_at":"2025-02-28T08:32:43.636Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/mipengine.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2018-09-06T09:06:02.000Z","updated_at":"2019-02-15T08:46:46.000Z","dependencies_parsed_at":null,"dependency_job_id":"4f30f274-1baf-498a-aa9b-c59dea0ea182","html_url":"https://github.com/mipengine/mip-cli-plugin-sf","commit_stats":null,"previous_names":[],"tags_count":3,"template":false,"template_full_name":null,"purl":"pkg:github/mipengine/mip-cli-plugin-sf","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mipengine%2Fmip-cli-plugin-sf","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mipengine%2Fmip-cli-plugin-sf/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mipengine%2Fmip-cli-plugin-sf/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mipengine%2Fmip-cli-plugin-sf/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/mipengine","download_url":"https://codeload.github.com/mipengine/mip-cli-plugin-sf/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mipengine%2Fmip-cli-plugin-sf/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":285884980,"owners_count":27248045,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","status":"online","status_checked_at":"2025-11-22T02:00:05.934Z","response_time":64,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-11-12T02:42:36.721Z","updated_at":"2025-11-23T01:04:30.408Z","avatar_url":"https://github.com/mipengine.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"## 项目背景\n\nMIP 页面在上线到搜索结果页之后，需要嵌入在 SuperFrame (简称 SF) 环境下运行。因此在开发后期，为了保证 MIP 页面的效果在上线后能保持一致，有必要创建一个线下 SF 调试环境并运行目标页面。\n\n在 MIP 官网 [https://www.mipengine.org/debug](https://www.mipengine.org/debug) 已经有这样一个线下 SF 调试环境，但有一个最大的问题：MIP 官网是 `https` 协议，当使用线下调试并且目标页面地址是 `http` 协议或者干脆 `localhost` 时，浏览器会阻挡请求，因为从 `https` 请求 `http` 是不安全的，影响了正常调试。而事实上，`http` 协议或者 `localhost` 又是开发时最最常用的情况。\n\n为了避开这个问题，本项目会在开发者本地启动一个服务。因为本身就启动在 `localhost`，因此无论是 `http` 还是 `https` 都是可以正常运行的。\n\n## 快速开始\n\n1. 全局安装 `mip2` 命令行工具\n\n    `npm i mip2 -g`\n\n2. 启动线下 SF 调试环境\n\n    `mip2 sf`\n\n3. 使用浏览器访问 (默认端口 8210)\n\n    `http://localhost:8210/sf`\n\n4. 在 URL 输入框 (第一个) 输入目标页面的 URL。__切记带上协议头，即 `http` 或者 `https`__\n\n    例如 `http://localhost:8111/xxx`\n\n5. 点击最下方的“出发测试”按钮\n\n## 分享链接\n\n有时候一个 MIP 页面是由多位开发者共同完成的，所以可能会有开发者 A 想把调试链接分享给开发者 B 的情况，直接分享 `http://localhost:8210/sf` 的话还需要 B 重新在 URL 框中输入地址，略微麻烦。因此这里我们还支持了 `url` 参数。\n\n你可以直接分享 `http://localhost:8210/sf?url=xxxx` 给你的同事，当然前提是他也在 `localhost` 启动着服务。或者如果你们处于同一个网段，你把自己的内网 IP 地址替换 `localhost` 分享给同事，也是一个可行 \u0026 简便的方案。\n\n## 一些解释\n\n* 线上/线下测试\n\n  MIP 页面在上线后，会由 mip-cache 系统把页面及其使用的资源全部转存到 CDN 中，并生成一个额外的 URL，我们称之为 `CACHE URL`，与之相对，原来的 URL 就称为 `原始 URL`。\n\n  举个例子，开发者开发了一个站点，入口页面为 `https://www.somesite.com/mip`，这就是 __原始 URL__。 上线并提交审核，同意收录之后，mip-cache 会把这个站点转存到 CDN 中，生成一个类似 `https://www-somesite-com.mipcdn.com/c/s/xxx` 之类的一个 URL，这就是 __CACHE URL__。注意到两个 URL 的域名并不相同，但当中有一些转化规则，可以让两者互相转化。这个规则开发者并不需要过多关心。\n\n  所谓线上测试，就是使用 SF 环境打开 CACHE URL，因此主要针对上线之后的站点。而所谓线下测试，则是使用 SF 环境打开原始 URL，因此主要针对上线之前，开发状态的站点。开发者应该大部分情况使用的是线下测试。\n\n  使用线上测试时， 会检查当前域名是否是百度域 (`*.baidu.com`)，如果不是，会返回 403 阻止请求。__因此想使用线上测试时，使用 `localhost` 是不行的。开发者需要配置 host，把例如 `test.baidu.com` 指向 `127.0.0.1`，之后使用 `test.baidu.com:8210/sf` 进行访问才可以正常显示页面。__\n\n* 目标页面的 LOGO URL 和标题\n\n  在调试页面，除了 URL 输入框和最后的测试按钮之外，当中还有两个选填框。这是为了在点击测试，到实际展现页面之前，中间那个 SF 的 loading 页面上显示 LOGO 和标题所用的。之所以选填，也是因为对实际测试影响很小，不追求完美的开发者可以忽略。\n\n## 其他参数\n\n* 指定端口号\n\n  `mip2 sf -p 8080`\n\n* 启动后自动打开网页\n\n  `mip2 sf -o`\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmipengine%2Fmip-cli-plugin-sf","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmipengine%2Fmip-cli-plugin-sf","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmipengine%2Fmip-cli-plugin-sf/lists"}