{"id":39548050,"url":"https://github.com/muhfajar/go-zero-cors-middleware","last_synced_at":"2026-01-18T06:49:46.125Z","repository":{"id":57633363,"uuid":"413652148","full_name":"muhfajar/go-zero-cors-middleware","owner":"muhfajar","description":"Go-Zero Middleware to handle CORS request","archived":false,"fork":false,"pushed_at":"2021-10-11T14:22:21.000Z","size":36,"stargazers_count":2,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"main","last_synced_at":"2023-07-27T22:23:41.044Z","etag":null,"topics":["cors","go-zero","middleware"],"latest_commit_sha":null,"homepage":"","language":"Go","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/muhfajar.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":"2021-10-05T02:46:34.000Z","updated_at":"2023-05-14T07:51:09.000Z","dependencies_parsed_at":"2022-08-31T16:32:00.306Z","dependency_job_id":null,"html_url":"https://github.com/muhfajar/go-zero-cors-middleware","commit_stats":null,"previous_names":[],"tags_count":2,"template":null,"template_full_name":null,"purl":"pkg:github/muhfajar/go-zero-cors-middleware","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/muhfajar%2Fgo-zero-cors-middleware","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/muhfajar%2Fgo-zero-cors-middleware/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/muhfajar%2Fgo-zero-cors-middleware/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/muhfajar%2Fgo-zero-cors-middleware/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/muhfajar","download_url":"https://codeload.github.com/muhfajar/go-zero-cors-middleware/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/muhfajar%2Fgo-zero-cors-middleware/sbom","scorecard":{"id":667555,"data":{"date":"2025-08-11","repo":{"name":"github.com/muhfajar/go-zero-cors-middleware","commit":"8c5bbca6202a08acd5131beb9e6957c48981231d"},"scorecard":{"version":"v5.2.1-40-gf6ed084d","commit":"f6ed084d17c9236477efd66e5b258b9d4cc7b389"},"score":3,"checks":[{"name":"Maintained","score":0,"reason":"0 commit(s) and 0 issue activity found in the last 90 days -- score normalized to 0","details":null,"documentation":{"short":"Determines if the project is \"actively maintained\".","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#maintained"}},{"name":"Token-Permissions","score":-1,"reason":"No tokens found","details":null,"documentation":{"short":"Determines if the project's workflows follow the principle of least privilege.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#token-permissions"}},{"name":"SAST","score":0,"reason":"no SAST tool detected","details":["Warn: no pull requests merged into dev branch"],"documentation":{"short":"Determines if the project uses static code analysis.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#sast"}},{"name":"Pinned-Dependencies","score":-1,"reason":"no dependencies found","details":null,"documentation":{"short":"Determines if the project has declared and pinned the dependencies of its build process.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#pinned-dependencies"}},{"name":"Packaging","score":-1,"reason":"packaging workflow not detected","details":["Warn: no GitHub/GitLab publishing workflow detected."],"documentation":{"short":"Determines if the project is published as a package that others can easily download, install, easily update, and uninstall.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#packaging"}},{"name":"Code-Review","score":0,"reason":"Found 0/11 approved changesets -- score normalized to 0","details":null,"documentation":{"short":"Determines if the project requires human code review before pull requests (aka merge requests) are merged.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#code-review"}},{"name":"Dangerous-Workflow","score":-1,"reason":"no workflows found","details":null,"documentation":{"short":"Determines if the project's GitHub Action workflows avoid dangerous patterns.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#dangerous-workflow"}},{"name":"Binary-Artifacts","score":10,"reason":"no binaries found in the repo","details":null,"documentation":{"short":"Determines if the project has generated executable (binary) artifacts in the source repository.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#binary-artifacts"}},{"name":"CII-Best-Practices","score":0,"reason":"no effort to earn an OpenSSF best practices badge detected","details":null,"documentation":{"short":"Determines if the project has an OpenSSF (formerly CII) Best Practices Badge.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#cii-best-practices"}},{"name":"Security-Policy","score":0,"reason":"security policy file not detected","details":["Warn: no security policy file detected","Warn: no security file to analyze","Warn: no security file to analyze","Warn: no security file to analyze"],"documentation":{"short":"Determines if the project has published a security policy.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#security-policy"}},{"name":"Fuzzing","score":0,"reason":"project is not fuzzed","details":["Warn: no fuzzer integrations found"],"documentation":{"short":"Determines if the project uses fuzzing.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#fuzzing"}},{"name":"License","score":10,"reason":"license file detected","details":["Info: project has a license file: LICENSE:0","Info: FSF or OSI recognized license: MIT License: LICENSE:0"],"documentation":{"short":"Determines if the project has defined a license.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#license"}},{"name":"Signed-Releases","score":-1,"reason":"no releases found","details":null,"documentation":{"short":"Determines if the project cryptographically signs release artifacts.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#signed-releases"}},{"name":"Branch-Protection","score":0,"reason":"branch protection not enabled on development/release branches","details":["Warn: branch protection not enabled for branch 'main'"],"documentation":{"short":"Determines if the default and release branches are protected with GitHub's branch protection settings.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#branch-protection"}},{"name":"Vulnerabilities","score":10,"reason":"0 existing vulnerabilities detected","details":null,"documentation":{"short":"Determines if the project has open, known unfixed vulnerabilities.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#vulnerabilities"}}]},"last_synced_at":"2025-08-21T18:37:54.308Z","repository_id":57633363,"created_at":"2025-08-21T18:37:54.309Z","updated_at":"2025-08-21T18:37:54.309Z"},"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":28532040,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-01-18T00:39:45.795Z","status":"online","status_checked_at":"2026-01-18T02:00:07.578Z","response_time":98,"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":["cors","go-zero","middleware"],"created_at":"2026-01-18T06:49:45.499Z","updated_at":"2026-01-18T06:49:46.113Z","avatar_url":"https://github.com/muhfajar.png","language":"Go","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Go-Zero Middleware to handle CORS request\n[![Build Status](https://app.travis-ci.com/muhfajar/go-zero-cors-middleware.svg?branch=main\u0026status=passed)](https://app.travis-ci.com/muhfajar/go-zero-cors-middleware)\n[![codecov](https://codecov.io/gh/muhfajar/go-zero-cors-middleware/branch/main/graph/badge.svg?token=1FB5E5PDCH)](https://codecov.io/gh/muhfajar/go-zero-cors-middleware)\n\n## Getting Started\n\nInstall `middleware`:\n\n    go get github.com/muhfajar/go-zero-cors-middleware\n\n\nAfter setting up your [Go-Zero](https://go-zero.dev/en/) project, update your `main` package to register CORS middleware.\n\n```\npackage main\n\nimport (\n\t\"flag\"\n\t\"fmt\"\n\n\t\"github.com/muhfajar/go-zero-cors-middleware/test/greet/internal/config\"\n\t\"github.com/muhfajar/go-zero-cors-middleware/test/greet/internal/handler\"\n\t\"github.com/muhfajar/go-zero-cors-middleware/test/greet/internal/svc\"\n\n\tmiddleware \"github.com/muhfajar/go-zero-cors-middleware\"\n\t\"github.com/tal-tech/go-zero/core/conf\"\n\t\"github.com/tal-tech/go-zero/rest\"\n)\n\nvar configFile = flag.String(\"f\", \"etc/greet-api.yaml\", \"the config file\")\n\nfunc main() {\n\tflag.Parse()\n\n\tvar c config.Config\n\tconf.MustLoad(*configFile, \u0026c)\n\n\tctx := svc.NewServiceContext(c)\n\t\n\t// Register go-zero-cors-middleware handler to handle preflight request\n\tcors := middleware.NewCORSMiddleware(\u0026middleware.Options{})\n\t\n\t// Add run option WithNotAllowedHandler and register `.Handler()` to handle `OPTIONS` request (preflight)\n\tserver := rest.MustNewServer(c.RestConf,\n\t    rest.WithNotAllowedHandler(cors.Handler()),\n\t)\n\n\tdefer server.Stop()\n\n\thandler.RegisterHandlers(server, ctx)\n\n\t// Register go-zero-cors-middleware\n\tserver.Use(cors.Handle)\n\n\tfmt.Printf(\"Starting server at %s:%d...\\n\", c.Host, c.Port)\n\tserver.Start()\n}\n```\n\nAvailable options\n\n```\nAllowCredentials bool       Indicates whether the request can include user credentials like cookies, HTTP authentication or client side SSL certificates.\nAllowHeaders     []string   A list of non simple headers the client is allowed to use with cross-domain requests.\nAllowMethods     []string   A list of methods the client is allowed to use with cross-domain requests.\nExposeHeaders    []string   Indicates which headers are safe to expose to the API of a CORS API specification.\n```\n\nDefault value\n\n```\nAllowCredentials    false\nAllowHeaders        []string{\"Content-Type\", \"X-CSRF-Token\", \"Authorization\", \"AccessToken\", \"Token\"}\nAllowMethods        []string{\"GET\", \"POST\", \"PUT\", \"DELETE\", \"OPTIONS\", \"PATCH\"}\nExposeHeaders       []string{\"Content-Length\", \"Content-Type\", \"Access-Control-Allow-Origin\", \"Access-Control-Allow-Headers\"}\n```\n\nBy default, if request `Origin` header value is null or not included in request and `AllowCredentials` is not set in options, `Access-Control-Allow-Origin` will be return `*`.\nBut if `AllowCredentials` set by `true` value and request `Origin` header value is present, `Access-Control-Allow-Origin` will be reflected by the request `Origin` value.\n\n## Licenses\n\nAll source code is licensed under the [MIT License](https://github.com/muhfajar/go-zero-cors-middleware/main/LICENSE).","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmuhfajar%2Fgo-zero-cors-middleware","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmuhfajar%2Fgo-zero-cors-middleware","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmuhfajar%2Fgo-zero-cors-middleware/lists"}