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

Authorization Header Not Sent #21

Open
AbdallahTarabish opened this issue Mar 27, 2023 · 0 comments
Open

Authorization Header Not Sent #21

AbdallahTarabish opened this issue Mar 27, 2023 · 0 comments

Comments

@AbdallahTarabish
Copy link

AbdallahTarabish commented Mar 27, 2023

let reply = await r.subrequest('/auth' , {
         method: 'POST',
         body: JSON.stringify({ username: "test", password: "test" })},);
    let response = JSON.parse((reply.responseBody));
    let token = response['token'];

    if (!token) {
     throw new Error("Failed to retrieve token from authentication endpoint");
    }

    var subrequestHeaders = {
      "Authorization": "Bearer " + token,
      "Content-Type": "application/json"
     };
    let backend_reply = await r.subrequest('/api/users', {
      headers: subrequestHeaders
      });

r.return(backend_reply.status, JSON.stringify(backend_reply));

 }catch (e) {
    r.return(500, e);
} 
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant