EncodeURIComponent within the params option returns a 404 for a GET request
See original GitHub issueI am fetching a video over the web, convert it to blob/objectURL and return the blob url. The param I am passing to the endpoint URL is a URL itself so I need to encode it to make sure characters that need escaping end up correct. But axios throws me a 404 error in that case. While if I pass the url directly, without encoding it first, status is 200.
This throws a 404:
return axios(endpoint, {
method: 'GET',
params: { url: encodeURIComponent(url) },
responseType: 'arraybuffer',
headers: new Headers({'Access-Control-Allow-Origin': '*'})
})
This is OK 200:
return axios(endpoint, {
method: 'GET',
params: { url: url },
responseType: 'arraybuffer',
headers: new Headers({'Access-Control-Allow-Origin': '*'})
})
_BUT_, if I include the encoding directly in the endpoint without using the params
option, status is 200, like so:
return axios(
`${endpoint}?url=${encodeURIComponent(url)}`, {
method: 'GET',
responseType: 'arraybuffer',
headers: new Headers({'Access-Control-Allow-Origin': '*'})
})
Is that normal behavior?
Issue Analytics
- State:
- Created 7 years ago
- Comments:5 (1 by maintainers)
Top Results From Across the Web
Getting a 404 error with parameters which contain periods ...
Try using ajax post method $.ajax({ url: url+ + "/", type: 'POST', data: {data1:encodeURIComponent(text1),data2:encodeURIComponent(text2)}, ...
Read more >encodeURIComponent() - JavaScript - MDN Web Docs
Parameters. uriComponent. A string to be encoded as a URI component (a path, query string, fragment, etc.) ...
Read more >Lambda@Edge example functions - Amazon CloudFront
For Node.js functions, each function must call the callback parameter to successfully process a request or return a response.
Read more >Problem with encoded parameters - MSDN - Microsoft
of these characters using both javascripts 'encodeURIComponent() and ... use thisstring as part of my URL, the URL returns 404 bad request.
Read more >REST Get - SnapLogic Documentation - Confluence
You can use the REST Get Snap to execute an HTTP Get method on a REST API ... In some cases, the request...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
When I use axios.get(url, params),it didn’t encodes at all, but if I encode params manually, it will encodes my params twice
Is there a way to disable encoding of the url?