How did you install Laravel?

|
rrajesh011 2020-01-13 16:11:10
2020-01-13 16:10:44
Access-Control-Allow-Origin *;
Access-Control-Expose-Headers true;

Where to add?

2020-01-13 16:11:32
rrajesh011 2020-01-13 16:10:38
None of them are working

If you are using nginx add these headers in your config file like this:

location ~* “^.*?.(eot)|(ttf)|(woff)$” {
add_header Access-Control-Allow-Origin *;
add_header Access-Control-Expose-Headers true;
}

rrajesh011 2020-01-13 16:11:49
Apache is there
2020-01-13 16:11:59
2020-01-13 16:11:32
If you are using nginx add these headers in your config file like this:

location ~* “^.*?.(eot)|(ttf)|(woff)$” {
add_header Access-Control-Allow-Origin *;
add_header Access-Control-Expose-Headers true;
}

Of course this only works for fonts! You can change the regex

rrajesh011 2020-01-13 16:12:08
Can i add those line in public/.htaccess file?
2020-01-13 16:12:10
rrajesh011 2020-01-13 16:11:49
Apache is there

I told you, just add the headers.

2020-01-13 16:12:42
rrajesh011 2020-01-13 16:12:08
Can i add those line in public/.htaccess file?

Nope. It’s different. Google the solution. Search: How to add headers in Apache or htaccess!

and then add

Access-Control-Allow-Origin *;
Access-Control-Expose-Headers true;

rrajesh011 2020-01-13 16:13:01
2020-01-13 16:12:42
Nope. It’s different. Google the solution. Search: How to add headers in Apache or htaccess!

and then add

Access-Control-Allow-Origin *;
Access-Control-Expose-Headers true;

Ok

rrajesh011 2020-01-13 16:13:05
Let me try
rrajesh011 2020-01-13 16:29:36
2020-01-13 16:12:42
Nope. It’s different. Google the solution. Search: How to add headers in Apache or htaccess!

and then add

Access-Control-Allow-Origin *;
Access-Control-Expose-Headers true;

Not working

rrajesh011 2020-01-13 16:29:44
Added in httpd.conf
2020-01-13 16:30:19
rrajesh011 2020-01-13 16:29:36
Not working

I’ll. Send me your response headers

2020-01-13 16:31:11
laravel_discuss-23994.jpg
It must be something like this
rrajesh011 2020-01-13 16:31:41
laravel_discuss-23996.jpg

2020-01-13 16:32:11
rrajesh011 2020-01-13 16:31:41

As you can se there isn’t Access-Control-Allow-Origin *!

rrajesh011 2020-01-13 16:32:45
2020-01-13 16:32:11
As you can se there isn’t Access-Control-Allow-Origin *!

I can see only request header

rrajesh011 2020-01-13 16:32:54
There is no response header
2020-01-13 16:33:08
You’re right 😀 I didn’t see that.
2020-01-13 16:33:52
rrajesh011 2020-01-13 16:31:41

Keep your network trac open and make a new request.

rrajesh011 2020-01-13 16:34:17
2020-01-13 16:33:52
Keep your network trac open and make a new request.

Same

rrajesh011 2020-01-13 16:34:35
I have created middle ware too for cors
2020-01-13 16:34:57
Have no idea! But I’m sure there won’t be anything like allow-origin
rrajesh011 2020-01-13 16:35:06
laravel_discuss-24005.jpg

2020-01-13 16:35:25
rrajesh011 2020-01-13 16:35:06

Maybe it’s because of the cache or something. Sometimes happens.

rrajesh011 2020-01-13 16:35:27
rrajesh011 2020-01-13 16:35:06

Called this class to kernel.php

2020-01-13 16:39:37
rrajesh011 2020-01-13 16:10:04
Anyone knows the solution

you have to use cors

2020-01-13 16:40:12
https://github.com/fruitcake/laravel-cors

GitHub – fruitcake/laravel-cors: Adds CORS (Cross-Origin Resource Sharing) headers support in your Laravel applicationGitHub
Adds CORS (Cross-Origin Resource Sharing) headers support in your Laravel application – GitHub – fruitcake/laravel-cors: Adds CORS (Cross-Origin Resource Sharing) headers support in your Laravel ap…
2020-01-13 16:41:20
don’t kill yourself doing things that are already solved
2020-01-13 16:42:28
2020-01-13 16:41:20
don’t kill yourself doing things that are already solved

It’s not a big deal. He only needs to add 2 headers; that’s all!

2020-01-13 16:43:26
rrajesh011 2020-01-13 16:35:27
Called this class to kernel.php

By the way, some urls may not be effected when you add the headers using PHP. For example image, fonts and the other files.

2020-01-13 16:45:21
2020-01-13 16:42:28
It’s not a big deal. He only needs to add 2 headers; that’s all!

It’s not so much, it’s the same as you want to make

2020-01-13 16:45:47
rrajesh011 2020-01-13 16:35:06

class CORS
{
/**
* Handle an incoming request.
*
* @param IlluminateHttpRequest $request
* @param Closure $next
* @return mixed
*/
public function handle($request, Closure $next)
{
$response = $next($request);

$headers[‘Access-Control-Allow-Credentials’] = ‘true’;
$headers[‘Access-Control-Expose-Headers’] = ‘true’;
//$headers[‘Access-Control-Request-Method’] = ‘GET’;
$headers[‘Access-Control-Allow-Origin’] = ‘*’;;
//$headers[‘Access-Control-Max-Age’] = 86400; // cache for 1 day

foreach ($headers as $key => $value) $response->headers->set($key, $value);

return $response;
}
}

rrajesh011 2020-01-13 16:45:56
2020-01-13 16:40:12
https://github.com/fruitcake/laravel-cors

At my workplace composer is blocked

rrajesh011 2020-01-13 16:46:07
I can’t download this
2020-01-13 16:46:17
2020-01-13 16:45:47
class CORS
{
/**
* Handle an incoming request.
*
* @param IlluminateHttpRequest $request
* @param Closure $next
* @return mixed
*/
public function handle($request, Closure $next)
{
$response = $next($request);

$headers[‘Access-Control-Allow-Credentials’] = ‘true’;
$headers[‘Access-Control-Expose-Headers’] = ‘true’;
//$headers[‘Access-Control-Request-Method’] = ‘GET’;
$headers[‘Access-Control-Allow-Origin’] = ‘*’;;
//$headers[‘Access-Control-Max-Age’] = 86400; // cache for 1 day

foreach ($headers as $key => $value) $response->headers->set($key, $value);

return $response;
}
}

I had written a middle ware for this problem long time ago.

2020-01-13 16:48:25
2020-01-13 16:45:47
class CORS
{
/**
* Handle an incoming request.
*
* @param IlluminateHttpRequest $request
* @param Closure $next
* @return mixed
*/
public function handle($request, Closure $next)
{
$response = $next($request);

$headers[‘Access-Control-Allow-Credentials’] = ‘true’;
$headers[‘Access-Control-Expose-Headers’] = ‘true’;
//$headers[‘Access-Control-Request-Method’] = ‘GET’;
$headers[‘Access-Control-Allow-Origin’] = ‘*’;;
//$headers[‘Access-Control-Max-Age’] = 86400; // cache for 1 day

foreach ($headers as $key => $value) $response->headers->set($key, $value);

return $response;
}
}

You can add it to your middleware routes to add the headers cautiously. (There will be some security issuse if you add that header to all of the urls.)

2020-01-13 16:48:40
rrajesh011 2020-01-13 16:45:56
At my workplace composer is blocked

How did you install Laravel?

2020-01-13 16:49:56
2020-01-13 16:48:40
How did you install Laravel?

Maybe Git or copy & paste :))

rrajesh011 2020-01-13 16:50:08
2020-01-13 16:48:40
How did you install Laravel?

Via zip

2020-01-13 16:51:58
shoot the administrator and let him use composer 😂
rrajesh011 2020-01-13 16:53:57
2020-01-13 16:51:58
shoot the administrator and let him use composer 😂

They blocked stackoverflow too 😂😂

rrajesh011 2020-01-13 16:54:59
laravel_discuss-24030.jpg
Request is not reaching to middleware
rrajesh011 2020-01-13 16:55:20
laravel_discuss-24031.jpg

rrajesh011 2020-01-13 16:55:24
Here i have added
2020-01-13 16:57:09
if it is a midd that runs throughout the application yes. But it suits you register lower in the facades
2020-01-13 17:01:47
try it if it works for you
rrajesh011 2020-01-13 17:03:21
2020-01-13 17:01:47
try it if it works for you

I didn’t get that point

rrajesh011 2020-01-13 17:05:36
laravel_discuss-24037.jpg

rrajesh011 2020-01-13 17:05:50
laravel_discuss-24038.jpg

rrajesh011 2020-01-13 17:06:16
rrajesh011 2020-01-13 17:05:36

Check 2 diff error before and after adding header line in index.php

|