mirror of
https://github.com/pgadmin-org/pgadmin4.git
synced 2025-01-10 08:04:36 -06:00
713ddb5f62
Remove usage of Bootstrap in React components. #5701
29 lines
728 B
JavaScript
29 lines
728 B
JavaScript
/////////////////////////////////////////////////////////////
|
|
//
|
|
// pgAdmin 4 - PostgreSQL Tools
|
|
//
|
|
// Copyright (C) 2013 - 2023, The pgAdmin Development Team
|
|
// This software is released under the PostgreSQL Licence
|
|
//
|
|
//////////////////////////////////////////////////////////////
|
|
|
|
import axios from 'axios';
|
|
|
|
export function setPGCSRFToken(header, token) {
|
|
if (!token) {
|
|
// Throw error message.
|
|
throw new Error('csrf-token meta tag has not been set');
|
|
}
|
|
|
|
// Configure axios to set 'X-CSRFToken' request header for
|
|
// every requests.
|
|
axios.interceptors.request.use(function (config) {
|
|
config.headers[header] = token;
|
|
|
|
return config;
|
|
}, function (error) {
|
|
return Promise.reject(error);
|
|
});
|
|
|
|
}
|