This commit is contained in:
Luk 2026-01-21 12:15:11 +08:00
parent 4488ae5a5f
commit 81a47c5f31
3 changed files with 6 additions and 3 deletions

View File

@ -6,4 +6,4 @@ if [ -f .gitignore.local.txt ]; then cat .gitignore.local.txt >> .gitignore; fi;
echo
# usage in package.json:
# "to_merge_gitignore.sh": "curl -sSL https://git.tic.cc/npm/sysconfig/raw/branch/main/git-ignore-merge.sh | bash",
# "to_merge_gitignore.sh": "curl -sSL https://git.tic.cc/npm/sysconfig/raw/branch/main/gitignore_merge.sh | bash",

View File

@ -3,14 +3,17 @@ const https = require('https')
https
.get('https://api.ipify.org', (res) => {
// `curl -s https://ifconfig.me` returns the IP address only, but open the url in browser or with nodejs http module returns the HTML content
// `https://api.ipify.org` returns the IP address only with curl, browser or nodejs. But it seems it doesn't work in China.
let data = ''
res.on('data', (chunk) => (data += chunk))
res.on('end', () => {
// 仅提取返回的纯IP地址部分忽略HTML标签
const ip = data.trim().split(/\s+/)[0]
console.log('public ip:', ip)
// console.log('public ip:', ip)
if (ip.endsWith('.172')) {
console.log('production')
} else if (ip.endsWith('.60')) {
console.log('development')
} else {
console.log('development')
}