Category : header

Where can i put the Authorization header token in axios after dispatching login action with laravel passport authentication in a seprated vue.js project?I tried with setting it in main.js like this and doesnt work properly. After dispatching, In the QuestionIndex component, the axios call dont have the authorization header automatically. And by refreshing the page, ..

Read more

I’m developing a Laravel application and suddenly it is not receiving the Authorization header with token anymore. This is my .htaccess file script. <IfModule mod_rewrite.c> <IfModule mod_negotiation.c> Options -MultiViews -Indexes </IfModule> RewriteEngine On # Handle Authorization Header RewriteCond %{HTTP:Authorization} ^(.+)$ RewriteRule .* – [E=HTTP_AUTHORIZATION:%{HTTP:Authorization}] Header add Access-Control-Allow-Origin "http://localhost:8080" Header add Access-Control-Allow-Credentials "true" Header add Access-Control-Allow-Methods ..

Read more

public function addcart($request) { $patient_id = config(‘api.current_user.patient_id’) ? config(‘api.current_user.patient_id’) : 0; $patient = Patient::find($patient_id); $patient_diagnostic_cart = @unserialize($patient->diagnostic_cart); $response = []; if (!empty($patient_diagnostic_cart)) { if (in_array((int)$request->test_id, $patient_diagnostic_cart)) { // abort(400, "Test allready added"); $message = "Test allready added"; } else { array_push($patient_diagnostic_cart, (int)$request->test_id); $patient->diagnostic_cart = serialize($patient_diagnostic_cart); $patient->save(); $message = "Test added"; } } else { $patient_diagnostic_cart ..

Read more

My laravel app keeps injecting an extra unneeded value: My response headers from the server Access-Control-Allow-Headers: Origin, Content-Type, X-Auth-Token Access-Control-Allow-Methods: GET, PUT, POST, DELETE, OPTIONS, post, get Access-Control-Allow-Origin: chrome-extension://neaolbpebpidafhdpnkjkokbhcedmcge Access-Control-Allow-Origin: * I only want Access-Control-Allow-Origin: chrome-extension://neaolbpebpidafhdpnkjkokbhcedmcge please help remove the Access-Control-Allow-Origin: * one. here is my index.php header(‘Access-Control-Allow-Origin: chrome-extension://neaolbpebpidafhdpnkjkokbhcedmcge’); header(‘Access-Control-Allow-Methods: GET, PUT, POST, DELETE, OPTIONS, ..

Read more

I am using "darkaonline/l5-swagger" version 8.0 laravel(v 8.12) package for api documentation. My PHP version is 8.0.2. I created api annotation for GET and POST request. The post request automatically send "Origin" header. The Get method is not sending "Origin" header by default. Package link: https://github.com/DarkaOnLine/L5-Swagger I need two things for this: I want to ..

Read more

I want to add custom headers for every response from my Laravel project. I created a middleware using php artisan make:middleware customheaders then I used this code in customheaders middleware public function handle(Request $request, Closure $next) { $response = $next($request); $response->header(‘X-CUSTOM-HEADER’, ‘myCustomHeader’); return $response; } then I added my class to kernel protected $middleware = ..

Read more

i generated two tokens: tokenA = As2 … xxxxx //can perform ONLY create tokenB = Bs2 … xxxxx //can perform ONLY update i have the following problem $response = $this->withHeaders([ ‘Accept’ => ‘application/json’, ‘Authorization’ => ‘Bearer ‘.$tokenA], ])->post(‘/api/store’,$data); $response->assertStatus(201); //the store is made without problems $response = $this->withHeaders([ ‘Accept’ => ‘application/json’, ‘Authorization’ => ‘Bearer ‘.tokenB, ..

Read more

I have file saved in resource with .xlsx extension but while downloading from browser it appears as .xls $headers = [ ‘Content-Type’ => ‘application/vnd.openxmlformats-officedocument.spreadsheetml.sheet’, ‘Content-Length’ => filesize($path), ‘Cache-Control’ => ‘must-revalidate’, ‘Content-Transfer-Encoding’ => ‘binary’, ‘Content-Disposition’ => ‘attachment; filename="test.xlsx"’ ]; Sourc..

Read more

I would like to download files from a controller method with: public function ….(…){ ….. return response()->download(….); } But without cache, the function must re-validate the content and download a fresh download. I tried many different things like: return response()->header(‘Cache-Control’, ‘no-cache, must-revalidate’) return response()->download(..)->header(‘Cache-Control’, ‘no-cache, must-revalidate’) and none of that is working. The laravel responses ..

Read more