0

on navigating to watchlist page the pai gives response but on refreshing the page the api gives CORS error

`
    useEffect(() => {
    dispatch(myWatchListApi());
  }, [dispatch]);
//
 const config = {
      headers: `Authorization: ${token} `,
    };

    const { data } = await axios.get(
      `https://fxsignals.ae/admin/api/news_api/get_wishlist_by_user/${user_id}`,
      config
    );

`
2
  • Does this answer your question? ReactJS API Data Fetching CORS error Commented Jan 22, 2024 at 6:10
  • @PRATHEESHPCsometimes it is giving response but when refreshed it gives CORS ERROR Commented Jan 22, 2024 at 6:25

1 Answer 1

0

in config/cors.php

update paths key value like that

'paths' => ['api/*', 'sanctum/csrf-cookie', 'admin/api/*'],

and run again config cache command

php artisan config:cache
Sign up to request clarification or add additional context in comments.

3 Comments

it a ci3 project and there is no such file in my config folder.any other workaround??
@RohitRai then you why add laravel tag in this question?
sorry my bad . could you suggest some other solution

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.