I am trying to include secure token cookies in REST API requests to support JWT authentications and have been unable to find a native way to do so. My current solution involves writing raw JS and calling fetch directly:
return fetch('localhost:8080/api/login', {
method: 'POST',
credentials: 'include',
headers: {
'Content-Type': 'application/json',
},
body: JSON.stringify({ email: {{ui.loginForm.value.email}}, password: {{ui.loginForm.value.password}} }),
}).then((response) => response.text()).then(...);
However, this falls apart when using multiple environments with different endpoints in each since the URL is hardcoded here. So I am trying to solve for one of the following:
- A native way to pass the token cookie around
- Custom environment variables so that I can set the appropriate URL in each environment