Advertisement
Guest User

Untitled

a guest
Sep 20th, 2017
420
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.12 KB | None | 0 0
  1. public function handle($request, Closure $next)
  2. {
  3. $origin = $request->server('HTTP_ORIGIN');
  4. $domains = ['http://localhost:8080', 'http://localhost:3000'];
  5.  
  6. if ($origin) {
  7. if (in_array($origin, $domains)) {
  8. return $next($request)
  9. ->header('Access-Control-Allow-Origin', '*')
  10. ->header('Access-Control-Allow-Methods', 'GET, POST, PUT, DELETE, OPTIONS')
  11. ->header('Access-Control-Allow-Headers', 'Content-Type, Accept, Authorization, X-Requested-With, Application');
  12. }
  13. }
  14.  
  15. return $next($request);
  16. }
  17.  
  18. getSecretCode: function () {
  19. const data = {
  20. grant_type: 'password',
  21. client_id: 4,
  22. client_secret: 'yoT0rjWGHGbzAzbqJkkEEvCnPWcjRK79tSxhGLjH',
  23. username: 'domenica37@example.com',
  24. password: 'secret',
  25. scope: '*',
  26. }
  27.  
  28. axios.post('http://127.0.0.1:8000/oauth/token', {data}).then((response) => {
  29. console.log(response);
  30. }, (error) => {
  31. console.log(error)
  32. })
  33.  
  34. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement