-
Notifications
You must be signed in to change notification settings - Fork 644
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Cross-site Request Forgery (CSRF) issue with Axios, replace with fetch? #1065
Comments
If you would like to upvote the priority of this issue, please comment below or react on the original post above with 👍 so we can see what is popular when we triage.@alexbjorlig Thank you for opening this issue. 🙏
This is an automated message, feel free to ignore. |
@alexbjorlig did you resort to using fetch? |
@flashblaze I reported this, because this repo is using Axios - not me 😎 |
That issue doesn't affect our library at all and only applies for usage of axios in the browser. |
100% - would be amazing if npm security audits were more intelligent, but well 😅 |
There still is an issue with other then Node and browser environments - Cloudlfare, Deno etc. where Axios does not work (and they are not interested in supporting it). |
Possible workaround is to use this library only for types, but send requests by anything our environment likes: import { defaultUrl, PlaceAutocompleteRequest, PlaceAutocompleteResponseData } from '@googlemaps/google-maps-services-js/dist/places/autocomplete'
const { googleMapsApiKey } = useRuntimeConfig()
export default defineEventHandler<{ query: {
input: string
language: string
sessionToken: string
} }>(async (event) => {
const { input, language, sessionToken } = getQuery(event)
try {
const data = await $fetch<PlaceAutocompleteResponseData>(defaultUrl, {
query: {
input,
language,
key: googleMapsApiKey,
sessiontoken: sessionToken,
} as PlaceAutocompleteRequest['params']
})
if (data.status !== 'OK' && data.status !== 'ZERO_RESULTS')
throw createError({ statusCode: 400, statusMessage: 'Bad Request' })
return data
}
catch (err) {
console.log(err)
throw createError({ statusCode: 500, statusMessage: 'Internal Server Error' })
}
}) |
There is a new CSRF issue with Axios, check more here: https://security.snyk.io/vuln/SNYK-JS-AXIOS-6032459
Maybe it's time to switch Axios with fetch? Would also make it more easy to support different runtimes than Node.js - like Cloudflare workers.
The text was updated successfully, but these errors were encountered: