Skip to content

Commit

Permalink
perf: pass authorization header to backend
Browse files Browse the repository at this point in the history
  • Loading branch information
Soulter committed Sep 16, 2024
1 parent 9435ab3 commit 4a2f0d1
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 6 deletions.
6 changes: 1 addition & 5 deletions frontend/src/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -39,11 +39,7 @@ const bus = mitt()
// app.config.globalProperties.$axios = { ...axiosInstance }
// })

const axiosInstance = axios.create({
withCredentials: true,
baseURL: store.state.base_url,
})
app.config.globalProperties.$axios = { ...axiosInstance }
app.config.globalProperties.$axios = axios

app.config.globalProperties.$bus = bus

Expand Down
2 changes: 1 addition & 1 deletion frontend/src/pages/world.vue
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@
</template>

<script>
import PostCard from '@/components/PostCard.vue'
export default {
data() {
return {
Expand Down
4 changes: 4 additions & 0 deletions frontend/src/utils/axios-wrapper.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import axios from 'axios';
import store from '@/store/index.js'

axios.interceptors.request.use(function (config) {
// add Authorization header before request is sent
Expand All @@ -12,4 +13,7 @@ axios.interceptors.request.use(function (config) {
return Promise.reject(error);
});

axios.defaults.withCredentials = true;
axios.defaults.baseURL = store.state.base_url;

export default axios;

0 comments on commit 4a2f0d1

Please sign in to comment.