{"id":19065474,"url":"https://github.com/menci/service-worker-redirect-origin","last_synced_at":"2025-04-28T11:28:11.074Z","repository":{"id":41255508,"uuid":"444811962","full_name":"Menci/service-worker-redirect-origin","owner":"Menci","description":"Redirect requests of current origin to another domain with Service Worker.","archived":false,"fork":false,"pushed_at":"2022-12-13T15:19:09.000Z","size":31,"stargazers_count":12,"open_issues_count":1,"forks_count":1,"subscribers_count":2,"default_branch":"main","last_synced_at":"2025-04-18T15:17:32.486Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"TypeScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/Menci.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2022-01-05T13:22:58.000Z","updated_at":"2024-06-19T08:50:41.000Z","dependencies_parsed_at":"2023-01-11T17:22:05.088Z","dependency_job_id":null,"html_url":"https://github.com/Menci/service-worker-redirect-origin","commit_stats":null,"previous_names":[],"tags_count":3,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Menci%2Fservice-worker-redirect-origin","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Menci%2Fservice-worker-redirect-origin/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Menci%2Fservice-worker-redirect-origin/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Menci%2Fservice-worker-redirect-origin/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/Menci","download_url":"https://codeload.github.com/Menci/service-worker-redirect-origin/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":251304073,"owners_count":21567801,"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","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-09T00:50:12.726Z","updated_at":"2025-04-28T11:28:11.056Z","avatar_url":"https://github.com/Menci.png","language":"TypeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Service Worker to Redirect Origin\n\nThis is a tool for your static website which could intercept all `GET` requests of the origin domain and redirect them to a given base-URL. Such as `/index.html` to `https://cdn.example.com/index.html`.\n\nIt's useful when your origin domain have no ICP license but you want to optimize mainland China routing.\n\n# Usage\n\n## GitHub Action\n\n```yaml\n- name: Inject Service Worker\n  uses: Menci/service-worker-redirect-origin@beta-v2\n  with:\n    # The directory containing your built static website files.\n    www-root: public\n\n    # The target base-URL to redirect to.\n    target-base-url: https://cdn.example.com/ # Remember to end with a \"/\"\n\n    # If https://cdn.example.com/\u003crequested url\u003e responds with 404, it's will be fetched.\n    # Omit to fallback to origin.\n    http-404-page: 404.html\n    \n    # The script filename of service worker. Will be written to the `www-root` directory.\n    # By default `sw.js`.\n    service-worker-filename: sw.js\n```\n\n## Node.js\n\n\n```bash\n$ yarn inject \u003cwwwRoot\u003e \u003ctargetBaseUrl\u003e [404Page] [serviceWorkerFilename]\n```\n\nSee the explanation for each arguments above in GitHub Action usage.\n\n# Limitations\n\nIt will replace your existing Service Worker in your site (if any).\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmenci%2Fservice-worker-redirect-origin","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmenci%2Fservice-worker-redirect-origin","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmenci%2Fservice-worker-redirect-origin/lists"}