redux_jwt_auth's Issues
CORS issue
@gitdagray Thanks for the tutorial and code. It really helps.
I faced CORS issue if we use "credentials: 'include'" when the server has allow orgin as "*". Since we are using API Tokens, do we need this flag? Can we change it to "credentials: 'omit'" ?
(Since this flag is only need for cookies)
Redux toolkit is not sending the headers
@gitdagray Thanks for the tutorial and code. It really helps.
I'm having a problem and I don't know what's going on, it seems that the header is not being set or sent correctly
`
const baseQuery = fetchBaseQuery({
baseUrl: "http://localhost:7000/api/v1",
credentials: 'included',
prepareHeaders: (headers: any, { getState }: any) => {
const token = getState().auth.token;
if(token) {
headers.set('Authorization', 'Bearer ${token}');
}
headers.set("Content-Type", "application/json");
return headers;
}
})
`
The server app is waiting for application/json Content-Type, but the redux toolkit is sendig text/plain;charset=UTF-8
Response Headers
Access-Control-Allow-Origin: http://localhost:3000
Connection: keep-alive
Content-Length: 249
Content-Type: application/json; charset=utf-8
Date: Sun, 12 Feb 2023 09:14:23 GMT
ETag: W/"f9-EV+UiIlBIZrmmi16jOp8t3c7b8I"
Keep-Alive: timeout=5
Vary: Origin
X-Powered-By: Express
Request Headers
accept: /
Accept-Encoding: gzip, deflate, br
Accept-Language: pt-BR,pt;q=0.9,en-US;q=0.8,en;q=0.7,la;q=0.6
Connection: keep-alive
Content-Length: 51
Content-Type: text/plain;charset=UTF-8
Host: localhost:7000
Origin: http://localhost:3000
Referer: http://localhost:3000/
sec-ch-ua: "Not_A Brand";v="99", "Google Chrome";v="109", "Chromium";v="109"
sec-ch-ua-mobile: ?0
sec-ch-ua-platform: "Linux"
Sec-Fetch-Dest: empty
Sec-Fetch-Mode: no-cors
Sec-Fetch-Site: same-site
User-Agent: Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/109.0.0.0 Safari/537.36
do I miss something?
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. ๐๐๐
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google โค๏ธ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.