-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
refactor(app.vue): update API endpoint to '/json' for fetching IP
docs(DEVELOPERS.md): clarify branch name for PR submissions feat(nuxt.config.ts): add server middleware for '/raw' and '/json' routes chore(package.json): add resolution for 'supports-color' dependency refactor: replace ip.js with separate route handlers for '/json' and '/raw' The API endpoint in `app.vue` is updated to '/json' to align with the new route structure. The documentation is updated to specify the correct branch name for PR submissions, improving clarity for developers. The `nuxt.config.ts` file now includes server middleware for '/raw' and '/json' routes, allowing for more flexible handling of IP requests. The `package.json` file includes a resolution for the 'supports-color' dependency to ensure compatibility. The `ip.js` file is removed and replaced with separate route handlers for '/json' and '/raw', improving code organization and maintainability.
- Loading branch information
Showing
8 changed files
with
183 additions
and
165 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,9 @@ | ||
// https://nuxt.com/docs/api/configuration/nuxt-config | ||
export default defineNuxtConfig({ | ||
compatibilityDate: '2024-11-01', | ||
devtools: { enabled: true } | ||
devtools: { enabled: true }, | ||
serverMiddleware: [ | ||
{ path: '/raw', handler: '~/server/ip.js' }, | ||
{ path: '/json', handler: '~/server/ip.js' }, | ||
], | ||
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -15,5 +15,8 @@ | |
"vue": "latest", | ||
"vue-router": "latest" | ||
}, | ||
"packageManager": "[email protected]+sha1.ac34549e6aa8e7ead463a7407e1c7390f61a6610" | ||
"packageManager": "[email protected]+sha1.ac34549e6aa8e7ead463a7407e1c7390f61a6610", | ||
"resolutions": { | ||
"supports-color": "7.1.0" | ||
} | ||
} |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
import { defineEventHandler, getRequestHeaders } from 'h3'; | ||
|
||
export default defineEventHandler((event) => { | ||
const headers = getRequestHeaders(event); | ||
const userIp = headers['x-forwarded-for'] || event.node.req.socket.remoteAddress; | ||
return { ip: userIp }; | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
import { defineEventHandler, getRequestHeaders } from 'h3'; | ||
|
||
export default defineEventHandler((event) => { | ||
const headers = getRequestHeaders(event); | ||
const userIp = headers['x-forwarded-for'] || event.node.req.socket.remoteAddress; | ||
event.res.setHeader('Content-Type', 'text/plain'); | ||
return userIp; | ||
}); |