{"id":17255572,"url":"https://github.com/ffmathy/fluffyspoon.ngrok","last_synced_at":"2025-09-14T04:31:57.908Z","repository":{"id":43253680,"uuid":"244133027","full_name":"ffMathy/FluffySpoon.Ngrok","owner":"ffMathy","description":"Integration of Ngrok with the AspNetCore pipeline. Tools to automatically create ngrok tunnels on application startup","archived":false,"fork":false,"pushed_at":"2024-01-13T22:51:42.000Z","size":15260,"stargazers_count":18,"open_issues_count":5,"forks_count":5,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-09-05T00:41:15.103Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"C#","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/ffMathy.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,"governance":null,"roadmap":null,"authors":null}},"created_at":"2020-03-01T11:00:40.000Z","updated_at":"2025-08-07T04:59:43.000Z","dependencies_parsed_at":"2024-01-15T22:00:35.872Z","dependency_job_id":null,"html_url":"https://github.com/ffMathy/FluffySpoon.Ngrok","commit_stats":{"total_commits":156,"total_committers":4,"mean_commits":39.0,"dds":0.3076923076923077,"last_synced_commit":"8faeaf2ea54a895d3a9bb696916d5e64bf16a28d"},"previous_names":["ffmathy/fluffyspoon.aspnet.ngrok"],"tags_count":59,"template":false,"template_full_name":null,"purl":"pkg:github/ffMathy/FluffySpoon.Ngrok","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ffMathy%2FFluffySpoon.Ngrok","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ffMathy%2FFluffySpoon.Ngrok/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ffMathy%2FFluffySpoon.Ngrok/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ffMathy%2FFluffySpoon.Ngrok/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/ffMathy","download_url":"https://codeload.github.com/ffMathy/FluffySpoon.Ngrok/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ffMathy%2FFluffySpoon.Ngrok/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":275062953,"owners_count":25398887,"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-09-14T02:00:10.474Z","response_time":75,"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-10-15T07:12:03.905Z","updated_at":"2025-09-14T04:31:57.857Z","avatar_url":"https://github.com/ffMathy.png","language":"C#","funding_links":[],"categories":[],"sub_categories":[],"readme":"# FluffySpoon.Ngrok\nA NuGet package used to start Ngrok programmatically and fetch the tunnel URL. Useful to enable for local development when a public URL is needed.\n\n# Examples\n## Console application\n\nAdd `AddNgrok` to your service registration\n\n```csharp\nvar services = new ServiceCollection();\n\nservices.AddNgrok(options =\u003e {\n    options.AuthToken = \"my auth token\"; //optional - only needed if tunneling HTML\n});\n\nvar serviceProvider = services.BuildServiceProvider();\nvar ngrokService = serviceProvider.GetService\u003cINgrokService\u003e();\n\n//this downloads the Ngrok executable and starts it in the background.\nawait ngrokService.InitializeAsync();\n\n//this opens a tunnel for the given URL\nvar tunnel = await ngrokService.StartAsync(new Uri(\"http://localhost:80\"));\nConsole.WriteLine(\"Ngrok tunnel URL for localhost:80 is: \" + tunnel.PublicUrl);\n\n//the active tunnel can also be accessed using ngrokService.ActiveTunnel.\n\n//we may stop the tunnel as well.\nawait ngrokService.StopAsync();\n```\n\n## ASP .NET Core application\nFor this example, the `FluffySpoon.Ngrok.AspNet` package has to be installed.\n\n```csharp\nvar builder = WebApplication.CreateBuilder();\n\n//this is the line that is needed to automatically start the tunnel with your ASP .NET Core application.\nbuilder.Services.AddNgrokHostedService(options =\u003e {\n    options.AuthToken = \"my auth token\"; //optional - only needed if tunneling HTML\n});\n\nbuilder.Services.AddControllersWithViews();\n\nvar app = builder.Build();\napp.UseStaticFiles();\napp.UseRouting();\napp.UseAuthorization();\napp.MapControllerRoute(\n    name: \"default\",\n    pattern: \"{controller=Home}/{action=Index}/{id?}\");\n\nawait app.RunAsync();\n```\n\n## Getting the tunnel URL\nTo get the tunnel URL in an ASP .NET Core application, you can just inject a `INgrokService` into your controller or class.\n\n```csharp\npublic class HomeController : Controller\n{\n    private readonly INgrokService _ngrokService;\n\n    public HomeController(INgrokService ngrokService)\n    {\n        _ngrokService = ngrokService;\n    }\n\n    public IActionResult Index()\n    {\n        var tunnel = await _ngrokService.ActiveTunnel;\n        Console.WriteLine(\"Tunnel URL is: \" + tunnel.PublicUrl);\n        \n        return View();\n    }\n}\n```\n\n## Waiting for the tunnel to be ready\nOn the `INgrokService`, you can call a method to wait for the tunnel to be ready.\n\n```csharp\nawait ngrokService.WaitUntilReadyAsync();\n```\n\n## Registering lifetime hooks\nThese are useful if you want to debug things like webhooks etc locally.\n\n```csharp\nclass SomeLifetimeHook : INgrokLifetimeHook\n{    \n    public Task OnCreatedAsync(TunnelResponse tunnel, CancellationToken cancellationToken)\n    {\n        //TODO: do something when a tunnel has been created. for instance, here you could register a webhook for \"tunnel.PublicUrl\".\n        return Task.CompletedTask;\n    }\n\n    public Task OnDestroyedAsync(TunnelResponse tunnel, CancellationToken cancellationToken)\n    {\n        //TODO: do something when a tunnel has been destroyed. for instance, here you could unregister a webhook for \"tunnel.PublicUrl\".\n        return Task.CompletedTask;\n    }\n}\n```\n\nAnd you can register a lifetime hook as such:\n\n```csharp\nservices.AddNgrokLifetimeHook\u003cMyHook\u003e();\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fffmathy%2Ffluffyspoon.ngrok","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fffmathy%2Ffluffyspoon.ngrok","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fffmathy%2Ffluffyspoon.ngrok/lists"}