<?php
return [
/*
|--------------------------------------------------------------------------
| Laravel CORS
|--------------------------------------------------------------------------
|
| allowedOrigins, allowedHeaders and allowedMethods can be set to array('*')
| to accept any value.
|
*/
'supportsCredentials' => false,
'allowedOrigins' => ['*'],
'allowedOriginsPatterns' => [],
'allowedHeaders' => ['*'],
'allowedMethods' => ['*'],
'exposedHeaders' => ['Content-Disposition'],
'maxAge' => 0,
];
Laravel: Controller
class UploadController extends Controller
{
protected $service;
public function __construct(UploadService $service)
{
$this->service = $service;
$this->middleware('auth:api');
}
public function show($identificador)
{
return $this->service->downloadArquivo((int) $identificador);
}
}
...
public function downloadArquivo($identificador)
{
$arquivo = $this->_obterArquivo($identificador);
if (empty($arquivo)) {
throw new EParametrosInvalidos("O arquivo solicitado não existe.");
}
return Storage::download($arquivo->ds_localizacao, $arquivo->no_arquivo);
}
This asserts the variable bar to have the type foo. Since TypeScript also uses angle brackets for type assertions, combining it with JSX’s syntax would introduce certain parsing difficulties. As a result, TypeScript disallows angle bracket type assertions in .tsx files.
Since the above syntax cannot be used in .tsx files, an alternate type assertion operator should be used: as. The example can easily be rewritten with the as operator.
var foo = bar as foo;
The as operator is available in both .ts and .tsx files, and is identical in behavior to the angle-bracket type assertion style.