-
-
Notifications
You must be signed in to change notification settings - Fork 72
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
[DataProvider] Empty Headers and 401 response #100
Comments
Hello, have you followed https://api-platform.com/docs/admin/authentication-support/? |
@alanpoulain Hello. Yes, I did all according to this documentation. |
It doesn't seem so. For instance: const customFetchHydra = (url, options = {}) => {
fetchHydra(url, {
...options,
headers: new Headers(getHeaders()),
})
}; Should be: const customFetchHydra = (url, options = {}) => {
fetchHydra(url, {
...options,
headers: getHeaders,
})
}; |
@alanpoulain i did it too. Was trying different variants and nothing change... |
You need to change the const apiDocumentationParser = async (entrypoint) => {
const { api } = await parseHydraDocumentation(entrypoint, { headers: getHeaders });
return { api };
}; |
@alanpoulain added as third parameter const apiDocumentationParser = async (entrypoint) => {
try {
const { api } = await parseHydraDocumentation(entrypoint, { headers: getHeaders });
return { api };
} catch (result) {
if (result.status === 401) {
// Prevent infinite loop if the token is expired
localStorage.removeItem("token");
return {
api: result.api,
customRoutes: [
<Route path="/" />
],
};
}
throw result;
}
};
const dataProvider = hydraDataProvider(API_ENTRYPOINT, customFetchHydra, apiDocumentationParser); And the same situation. I have no idea, it's my fail or bug... |
Find out that we have no header options at all: I can be mistaken... |
Closing because it was not followed. It seems other users don't have similar issues. Please reopen if it's the case. |
API Platform version(s) affected: 2.6.4
Description
I try to add JWT token to the header, but it stays empty no matter what returning 401 response.
How to reproduce
Possible Solution
~
Additional Context
![image](https://user-images.githubusercontent.com/4490762/123244576-bccf3a80-d4ec-11eb-9ec8-82fd5ff82f7a.png)
I tried to debug compiled fetchJsonLd.js:
then I was trying to show all headers in the chrome console at that moment:
![image](https://user-images.githubusercontent.com/4490762/123244967-0fa8f200-d4ed-11eb-96f4-2862077db4b8.png)
I have no idea where "next" comes from...
The text was updated successfully, but these errors were encountered: