Find DAWA calls in your code with migrate-cli
Find and replace DAWA URLs in a project with npx @danadresse/migrate-cli, see what the tool misses, and stop new DAWA calls in CI.
Before you can move off DAWA you need to know where the code calls DAWA. In an older project the URLs can sit in source code, configuration files, templates and documentation. @danadresse/migrate-cli finds them and can replace them with https://api.danadresse.dk.
This guide shows how to run the tool, exactly what it does, what it misses, and how to make CI fail if a DAWA URL shows up again.
1. Do a dry run
The tool needs Node 18 or newer. Stand in the project root and run:
npx @danadresse/migrate-cli
Without flags it changes nothing. It shows each line that would change and what it would look like afterwards:
Found 3 occurrence(s) in 2 file(s):
src/adresse.ts
12: const BASE = "https://dawa.aws.dk";
→ const BASE = "https://api.danadresse.dk";
templates/checkout.html
41: <script src="https://dawa.aws.dk/js/autocomplete/dawa-autocomplete2.min.js"></script>
→ <script src="https://api.danadresse.dk/js/autocomplete/dawa-autocomplete2.min.js"></script>
Run with --write to apply changes.2. Know the flags
| Command | Effect |
|---|---|
npx @danadresse/migrate-cli | Dry run of the current folder |
npx @danadresse/migrate-cli src/ | Dry run of src/ |
npx @danadresse/migrate-cli --target src/ or -t src/ | The same |
npx @danadresse/migrate-cli scan src/ | The same. scan is always a dry run |
npx @danadresse/migrate-cli --write or -w | Writes the changes to the files |
npx @danadresse/migrate-cli rewrite src/ | The same as --write on src/ |
npx @danadresse/migrate-cli --key dawa_live_… | Puts your key into the code examples at the end |
npx @danadresse/migrate-cli --fail-on-found or --ci | Dry run that exits with code 1 if anything was found. For CI |
npx @danadresse/migrate-cli --help | Shows the help |
--key does one thing: it shows the key in the examples. The tool never writes the key into your files. An unknown flag prints a warning, but the run continues.
3. Understand what gets replaced
The tool looks for DAWA's hosts, with or without http:// or https:// in front:
| Found | Becomes |
|---|---|
https://dawa.aws.dk | https://api.danadresse.dk |
https://api.dataforsyningen.dk | https://api.danadresse.dk |
https://cdn.dataforsyningen.dk followed by /dawa/assets/dawa-autocomplete2/ | https://api.danadresse.dk |
A bare host: dawa.aws.dk, //dawa.aws.dk/…, DAWA_HOST=api.dataforsyningen.dk | api.danadresse.dk |
Only the domain part is replaced. Path and parameters stay, so https://dawa.aws.dk/adresser?postnr=8000 becomes https://api.danadresse.dk/adresser?postnr=8000. That works because we have the same paths. http:// becomes https://, and a bare host stays a bare host. Look-alike hosts such as x.api.dataforsyningen.dk are left alone.
It reads files with these extensions: js ts jsx tsx mjs cjs py php rb go java cs kt swift rs html vue svelte astro json yaml yml env toml ini conf cfg md rst txt, plus .env, .env.* (such as .env.production), workflows under .github/ and .gitlab-ci.yml. The folders node_modules, .git, .cache, .yarn, .venv, venv, dist, build, __pycache__, .next and vendor are skipped.
If it finds DAWA's widget (dawa-autocomplete2.js or .min.js), it prints the new script tag with ?key= at the end. See From dawa-autocomplete2 for why that key must be a browser key.
4. What the tool does not catch
The scan is deliberately simple. Check these places yourself:
- Other hidden files. Apart from
.env*,.github/and.gitlab-ci.yml, files whose name starts with a dot are not scanned, for example.npmrcor.circleci/config.yml. - Concatenated strings.
"https://dawa." + "aws.dk"or a URL built in several steps. - Other file types. For example
.xml,.properties,.gradle,.twig,.liquid,.cshtml,.razor,.sqland spreadsheets. - Configuration outside the repository. Settings in a database, a CMS, environment variables on the server or a third-party plugin.
And after the replacement the calls still lack a key. Add X-Api-Key wherever you make HTTP calls. See Move from DAWA by changing the base URL.
5. Search yourself with ripgrep or git grep
A ripgrep search covers every file type and all hidden files:
rg -n --hidden -g '!.git' -g '!node_modules' \ -e 'dawa\.aws\.dk' \ -e 'api\.dataforsyningen\.dk' \ -e 'cdn\.dataforsyningen\.dk/dawa' \ .
git grep only searches files Git tracks, which is often what you want:
git grep -nE 'dawa\.aws\.dk|api\.dataforsyningen\.dk|cdn\.dataforsyningen\.dk/dawa'If you have neither, plain grep -rnE with the same pattern works, but then you have to exclude node_modules yourself.
6. Make CI fail if DAWA comes back
With --fail-on-found, migrate-cli exits with code 1 as soon as it finds a DAWA reference. It changes nothing:
npx --yes @danadresse/migrate-cli@latest --fail-on-found
It has no option to exclude files, so a changelog that mentions DAWA on purpose also fails the build. If you need exclusions, or do not want Node in the pipeline, use a small script instead. It fails if a tracked file mentions one of DAWA's domains:
#!/usr/bin/env bash # Fails if the code refers to DAWA again. Run from the repository root. set -euo pipefail pattern='dawa\.aws\.dk|api\.dataforsyningen\.dk|cdn\.dataforsyningen\.dk/dawa' # Exclude files that mention DAWA on purpose (e.g. this file and changelogs). if git grep -nE "$pattern" -- . ':!scripts/check-no-dawa.sh' ':!CHANGELOG.md'; then echo "DAWA closed on 1 October 2026. Use https://api.danadresse.dk instead." >&2 exit 1 fi echo "No DAWA URLs found."
Save it as scripts/check-no-dawa.sh and call it from your pipeline. In GitHub Actions:
name: no-dawa
on: [push, pull_request]
jobs:
check:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- run: bash scripts/check-no-dawa.shgit grep exits with code 1 when it finds nothing. That is why the call sits inside an if, so set -e does not stop the script on the good outcome.
Next steps
- Add the key and test the switch: Move from DAWA by changing the base URL.
- Ready for production? Go-live checklist.
Related guides
Markdown source Spotted an error? Tell us API-reference (Swagger)