-
-
Notifications
You must be signed in to change notification settings - Fork 2.6k
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
Other Content-Type Header when creating a post request with form data #2032
Comments
Can you share the code you're using to perform the HTTP request? The Also, you're using the default http client right? Not the reqwest one? |
I am using the tauri (version 1.0.0-beta.2) javascript api, i don't know which crate is used internally. The code i am using:
The server answers with HTTP status 415: Content type 'application/x-www-form-urlencoded' not supported. |
I just tried it. This is my backend code: const express = require('express');
const cors = require('cors');
const app = express();
app.use(cors())
app.get('/', (req, res) => {
console.log(req.headers)
res.json({
message: 'Hello World'
});
});
app.listen(2020, () => {
console.log('server is listening on port 2020');
}); And my fetch call: const options = {
method: "GET",
headers: {
'Content-Type': 'multipart/form-data'
}
};
options.body = Body.form({ a:'a', b: '5' })
fetch('http://localhost:2020', options) And the backend logs this:
Reach to us on Discord if you still can't figure it out. We can reopen this if it is an issue on another platform/http client. |
I'm reopening it since we need to fix this problem when using the reqwest client feature. |
Is your feature request related to a problem? Please describe.
Currently I am working on a client application, which communicates with a server that only accepts form data with the Content-Type "multipart/form-data" for uploading files. Setting the content type to "multipart/form-data" in the http.fetch method is not possible, it gets overwritten ("application/x-www-form-urlencoded").
Describe the solution you'd like
The Content-Type should just default to "application/x-www-form-urlencoded", manually setting the Content-Type should overwrite the default value.
The text was updated successfully, but these errors were encountered: