{"id":13484962,"url":"https://github.com/jakeburden/next-absolute-url","last_synced_at":"2025-04-05T21:33:50.710Z","repository":{"id":44012801,"uuid":"170043097","full_name":"jakeburden/next-absolute-url","owner":"jakeburden","description":"Get the absolute URL of your Next.js app (optionally set a localhost dev URL)","archived":false,"fork":false,"pushed_at":"2023-07-04T00:17:27.000Z","size":778,"stargazers_count":301,"open_issues_count":19,"forks_count":30,"subscribers_count":3,"default_branch":"master","last_synced_at":"2024-05-17T19:02:37.668Z","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":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/jakeburden.png","metadata":{"files":{"readme":"README.md","changelog":null,"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}},"created_at":"2019-02-11T00:15:58.000Z","updated_at":"2024-01-24T00:32:39.000Z","dependencies_parsed_at":"2023-07-14T01:02:26.213Z","dependency_job_id":null,"html_url":"https://github.com/jakeburden/next-absolute-url","commit_stats":null,"previous_names":["jekrb/next-absolute-url"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jakeburden%2Fnext-absolute-url","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jakeburden%2Fnext-absolute-url/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jakeburden%2Fnext-absolute-url/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jakeburden%2Fnext-absolute-url/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/jakeburden","download_url":"https://codeload.github.com/jakeburden/next-absolute-url/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247406077,"owners_count":20933803,"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-07-31T17:01:40.538Z","updated_at":"2025-04-05T21:33:50.690Z","avatar_url":"https://github.com/jakeburden.png","language":"TypeScript","funding_links":[],"categories":["TypeScript"],"sub_categories":[],"readme":"# next-absolute-url\n\n\u003e Get the protocol and host for the absolute URL of your Next.js app (and optionally set a dev url)\n\nThis module enables you to easily get the protocol and host of your Next.js app, both on the server and the client. Optionally, you can set a localhost variable, which is useful for local development if you have local lambda functions running on a different port.\n\n## Usage\n\n\u003e I'm honored that an excellent blog post has been published about this package. For detailed usage, please see: https://web.archive.org/web/20211110110818/https://codeconqueror.com/blog/get-the-current-url-in-next-js/\n\n```js\nimport absoluteUrl from 'next-absolute-url'\nconst { protocol, host } = absoluteUrl(req, 'localhost:8004')\nconst apiURL = `${protocol}//${host}/api/job.js`\n```\n\nor if you just want the full URL origin:\n\n```js\nimport absoluteUrl from 'next-absolute-url'\nconst { origin } = absoluteUrl(req)\nconst apiURL = `${origin}/api/job.js`\n```\n\nIf you deployed your Next.js app with `now` the `apiURL` will be something like `https://your-app.now.sh/api/job.js`.\n\nHowever, if you are running the app locally the `apiURL` will be `http://localhost:8004/api/job.js` instead.\n\n## Install\n\nWith [npm](https://npmjs.org/) installed, run\n\n```sh\nnpm install next-absolute-url\n```\n\nMIT\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjakeburden%2Fnext-absolute-url","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fjakeburden%2Fnext-absolute-url","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjakeburden%2Fnext-absolute-url/lists"}