Skip to content
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

GET /upload/files or any GET from content-types always returns 401. #20244

Closed
Luis-txd opened this issue May 2, 2024 · 4 comments
Closed

GET /upload/files or any GET from content-types always returns 401. #20244

Luis-txd opened this issue May 2, 2024 · 4 comments
Labels
flag: invalid template Automation Flag to handle invalid bug report templates flag: question Automation Flag to handle community questions

Comments

@Luis-txd
Copy link

Luis-txd commented May 2, 2024

Bug report

Required System information

  • Node.js version: 18.17.1
  • NPM version: 9.6.7
  • Strapi version: 4.21
  • Database: PostgresSQL
  • Operating system: Windows 11
  • Is your project Javascript or Typescript: Typescript

Describe the bug

I am developing my own plugin and i need access to the admin content-types and the files in the Media Library.
While using the useFetchClient, and properly setting the authorization token as the one in the local storage, any request to the content types or the media library return 401 (Unauthorized).

This issue happens even when the find and findOne are allowed for public access (and through the browser, i am able to acess that data).

Code snippets

const { get } = useFetchClient()

const fetchTags = async() => {
      await get("/api/news-tags", {
        headers: {
          "Authorization": "Bearer " + localStorage.getItem("token"),
        }
      })
        .then((response: any) => {
          console.log(response)
        })
        .catch((err:any) => {
          console.log("Err:", err);
        })
    }

fetchTags();

Thanks in advance for the help

@shubham9069
Copy link

shubham9069 commented May 2, 2024

Hi @Luis-txd can you please describe more about it? Please share the details about bug? Can you please replace your key name from "token" --> "jwtToken" and store it in local storage. Just hit and try may be this will work. I am not hardcore coder but just try it please .

@Luis-txd
Copy link
Author

Luis-txd commented May 2, 2024

What more information should i provide?
Basically any request to get the different content types from the admin return 401. Even if they are publicly accessible (i can access them through the browser, but never in the plugin).

That solution did not resolve the problem @shubham9069 . I should be able to access them even wittout tokens since they are publicly accessible.

@joshuaellis joshuaellis added the flag: invalid template Automation Flag to handle invalid bug report templates label May 14, 2024
Copy link
Contributor

This is a templated message

Hello @Luis-txd,

We ask that you please follow the issue template.
A proper issue submission let's us better understand the origin of your bug and therefore help you. We will reopen your issue when we receive the issue following the template guidelines and properly fill out the template. You can see the template guidelines for bug reports here.

Please update the issue with the template and we can reopen this report.

Thank you.

@github-actions github-actions bot closed this as not planned Won't fix, can't repro, duplicate, stale May 14, 2024
@joshuaellis joshuaellis added the flag: question Automation Flag to handle community questions label May 14, 2024
Copy link
Contributor

This is a templated message

Hello @Luis-txd,

I see you are wanting to ask a question that is not really a bug report,

Please see the following contributing guidelines for asking a question here.

Thank you.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
flag: invalid template Automation Flag to handle invalid bug report templates flag: question Automation Flag to handle community questions
Projects
Status: Done
Development

No branches or pull requests

3 participants