Closed fera765 closed 3 years ago
Hi there,
Those headers shouldn't be inside of prepareHeaders. You should only need to include credentials for authenticated endpoints from a client perspective.
Double check your server configuration and make sure you can hit your api with a tool like insomnia.rest or postman.
Additional reading: https://developer.mozilla.org/en-US/docs/Web/HTTP/CORS
Hi there,
Those headers shouldn't be inside of prepareHeaders. You should only need to include credentials for authenticated endpoints from a client perspective.
Double check your server configuration and make sure you can hit your api with a tool like insomnia.rest or postman.
Additional reading: https://developer.mozilla.org/en-US/docs/Web/HTTP/CORS
I was able to debug the application, and I was able to identify that the error is because of RateLimit
Too many requests per second are blocking, and my server is blocking... These settings are inside my API
import { RateLimiterRedis } from 'rate-limiter-flexible';
const redisClient = redis.createClient({
host: process.env.REDIS_HOST,
port: Number(process.env.REDIS_PORT),
password: process.env.REDIS_PASS,
});
const rate = new RateLimiterRedis({
storeClient: redisClient,
keyPrefix: 'middleware',
points: 5,
duration: 1,
});
is it wrong configuration, inside RTK-Query?
RTK query problem
Inside the api I have the cors imported from the state with app.use(cors ()), but still giving this same error ..
I also made the configuration inside the RTK header
Access to fetch at 'http://localhost:3333/post/view/5c42f13a-2456-4b1a-9209-d87778303c22' from origin 'http://localhost:3000' has been blocked by CORS policy: No 'Access-Control-Allow-Origin' header is present on the requested resource. If an opaque response serves your needs, set the request's mode to 'no-cors' to fetch the resource with CORS disabled. fetchBaseQuery.ts:30 GET http://localhost:3333/post/view/5c42f13a-2456-4b1a-9209-d87778303c22 net::ERR_FAILED