I have been creating a web application using ReactJS and Symfony, I want to add a multi language functionality to my application. The problem is when I add locale to requests as a header parameter, I'm getting a Failed to load response data
, also I see the message Provisional headers are shown
const instance = axios.create({
baseURL: 'myapp',
headers: {
'Content-Type': 'application/ld+json',
locale: 'en'
}});
when I remove the parameter locale it work correctly and the request passed to the API and the worning message "Provisional headers are shown" disappear from the browser.
how can I solve the problem ?. Thanks.
I have been creating a web application using ReactJS and Symfony, I want to add a multi language functionality to my application. The problem is when I add locale to requests as a header parameter, I'm getting a Failed to load response data
, also I see the message Provisional headers are shown
const instance = axios.create({
baseURL: 'myapp.',
headers: {
'Content-Type': 'application/ld+json',
locale: 'en'
}});
when I remove the parameter locale it work correctly and the request passed to the API and the worning message "Provisional headers are shown" disappear from the browser.
how can I solve the problem ?. Thanks.
Share Improve this question edited Jan 3, 2021 at 22:19 Naruto Uzumaki asked Jan 3, 2021 at 21:56 Naruto UzumakiNaruto Uzumaki 3182 gold badges7 silver badges11 bronze badges 5- Are any other error messages shown? This seems like the sort of thing that would trigger a CORS related error message. – Quentin Commented Jan 3, 2021 at 22:00
-
1
Why are you setting a header called
local
? That isn't even a word used for language related things (likelocale
) and there's a perfectly good, standardAccept-Language
request header! – Quentin Commented Jan 3, 2021 at 22:00 - I dont want to set Accept-Language, I want to add a new parameter locale to all requests. when I add it all request doesn't passed. then I see the message "Provisional headers are shown" in the browser (header section) – Naruto Uzumaki Commented Jan 3, 2021 at 22:13
- Leaving aside that it's bizarre to use a made up header instead of a standard one: You need to address my first ment. – Quentin Commented Jan 3, 2021 at 22:24
- @Quentin there aren't any other problem. – Naruto Uzumaki Commented Jan 3, 2021 at 22:31
2 Answers
Reset to default 4Do you mean you want to set the accept language?
headers: {
"Accept-Language": "en-US,en;"
}
I added the locale to the list of parameters accepted in the allow_header section of the API and now it works.
allow_headers: ['Content-Type', 'Authorization', 'locale']