Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

peterdickins's avatar

Add Authentication Headers

Hi,

II am building an app with a Laravel backend api and a vue.js front end.

Part of the application is password protected, so I am making requests with headers to authenticate, for example:

await axios
    .get(`/api/products/${param.productId}`, {
        headers: {
            Authorization: `Bearer ${userStore.user.token}`,
            token: userStore.user.token
        }
    })
    .then((response) => {
        localState.product = response.data.data
    });

Is there a way to add headers to all requests in the password protected area to tidy this up?

0 likes
1 reply

Please or to participate in this conversation.