Merge pull request #8 from apuc/authentication

no cors queries
This commit is contained in:
kavalar 2021-08-09 12:07:30 +03:00 committed by GitHub
commit c844def2a4
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -3,9 +3,9 @@ export const fetchProfile = async (link, index) => {
const response = await fetch(`${link}${index}`, { const response = await fetch(`${link}${index}`, {
method: 'GET', method: 'GET',
headers: { headers: {
'Access-Control-Request-Headers': 'authorization', // 'Access-Control-Request-Headers': 'authorization',
'Authorization': `Bearer ${localStorage.getItem('auth_token')}`, 'Authorization': `Bearer ${localStorage.getItem('auth_token')}`,
'Origin': `${process.env.REACT_APP_BASE_URL}`, // 'Origin': `${process.env.REACT_APP_BASE_URL}`,
} }
}) })
let data = await response.json() let data = await response.json()
@ -19,9 +19,9 @@ export const fetchSkills = async (link) => {
const response = await fetch(link, { const response = await fetch(link, {
method: 'GET', method: 'GET',
headers: { headers: {
'Access-Control-Request-Headers': 'authorization', // 'Access-Control-Request-Headers': 'authorization',
'Authorization': `Bearer ${localStorage.getItem('auth_token')}`, 'Authorization': `Bearer ${localStorage.getItem('auth_token')}`,
'Origin': `${process.env.REACT_APP_BASE_URL}`, // 'Origin': `${process.env.REACT_APP_BASE_URL}`,
} }
}) })
let data = await response.json() let data = await response.json()
@ -36,9 +36,9 @@ export const fetchItemsForId = async (link, id) => {
const response = await fetch(`${link}${id}`, { const response = await fetch(`${link}${id}`, {
method: 'GET', method: 'GET',
headers: { headers: {
'Access-Control-Request-Headers': 'authorization', // 'Access-Control-Request-Headers': 'authorization',
'Authorization': `Bearer ${localStorage.getItem('auth_token')}`, 'Authorization': `Bearer ${localStorage.getItem('auth_token')}`,
'Origin': `${process.env.REACT_APP_BASE_URL}`, // 'Origin': `${process.env.REACT_APP_BASE_URL}`,
} }
}) })
let data = await response.json() let data = await response.json()
@ -52,9 +52,9 @@ export const fetchForm = async (link, info) => {
const response = await fetch(link, { const response = await fetch(link, {
method: 'POST', method: 'POST',
headers: { headers: {
'Access-Control-Request-Headers': 'authorization', // 'Access-Control-Request-Headers': 'authorization',
'Authorization': `Bearer ${localStorage.getItem('auth_token')}`, 'Authorization': `Bearer ${localStorage.getItem('auth_token')}`,
'Origin': `${process.env.REACT_APP_BASE_URL}`, // 'Origin': `${process.env.REACT_APP_BASE_URL}`,
'Content-Type': 'multipart/form-data' 'Content-Type': 'multipart/form-data'
}, },
body: info body: info
@ -74,7 +74,7 @@ export const fetchAuth = async ({ username, password, dispatch }) => {
method: 'POST', method: 'POST',
headers: { headers: {
'Content-Type': 'application/json', 'Content-Type': 'application/json',
'Origin': `${baseURL}`, // 'Origin': `${baseURL}`,
}, },
body: JSON.stringify({ body: JSON.stringify({
username, username,