u
This commit is contained in:
parent
4488ae5a5f
commit
81a47c5f31
@ -6,4 +6,4 @@ if [ -f .gitignore.local.txt ]; then cat .gitignore.local.txt >> .gitignore; fi;
|
|||||||
echo
|
echo
|
||||||
|
|
||||||
# usage in package.json:
|
# 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",
|
||||||
@ -3,14 +3,17 @@ const https = require('https')
|
|||||||
|
|
||||||
https
|
https
|
||||||
.get('https://api.ipify.org', (res) => {
|
.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 = ''
|
let data = ''
|
||||||
res.on('data', (chunk) => (data += chunk))
|
res.on('data', (chunk) => (data += chunk))
|
||||||
res.on('end', () => {
|
res.on('end', () => {
|
||||||
// 仅提取返回的纯IP地址部分,忽略HTML标签
|
|
||||||
const ip = data.trim().split(/\s+/)[0]
|
const ip = data.trim().split(/\s+/)[0]
|
||||||
console.log('public ip:', ip)
|
// console.log('public ip:', ip)
|
||||||
if (ip.endsWith('.172')) {
|
if (ip.endsWith('.172')) {
|
||||||
console.log('production')
|
console.log('production')
|
||||||
|
} else if (ip.endsWith('.60')) {
|
||||||
|
console.log('development')
|
||||||
} else {
|
} else {
|
||||||
console.log('development')
|
console.log('development')
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user