Skip to content

Commit

Permalink
fix: corrects guards access to own API
Browse files Browse the repository at this point in the history
  • Loading branch information
eriandev committed May 7, 2023
1 parent 6d7ec6a commit ab3e311
Showing 1 changed file with 3 additions and 8 deletions.
11 changes: 3 additions & 8 deletions src/routes/api/weather/[endpoint]/+server.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,16 +7,11 @@ import { AVAIBLE_ENDPOINTS } from '$lib/server/consts'
* @type {import('./$types').RequestHandler}
* @see https://kit.svelte.dev/docs/routing#endpoints
*/
export async function GET (event) {
const {
params,
getClientAddress,
url: { searchParams }
} = event
export async function GET ({ url, params, getClientAddress }) {
const { endpoint = '' } = params
const query = searchParams.get('q') ?? getClientAddress()
const query = url.searchParams.get('q') ?? getClientAddress()

const isNotFromAppItself = !(event.request.url === BASE_URL)
const isNotFromAppItself = !(BASE_URL === url.origin)
const isNotAvailableEndpoint = !AVAIBLE_ENDPOINTS.includes(endpoint)

if (isNotFromAppItself) {
Expand Down

1 comment on commit ab3e311

@vercel
Copy link

@vercel vercel bot commented on ab3e311 May 7, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Successfully deployed to the following URLs:

weather-app – ./

weather-app-eriandev.vercel.app
eriandev-weather-app.vercel.app
weather-app-git-main-eriandev.vercel.app

Please sign in to comment.