Перенес запросы в api

This commit is contained in:
Dhaverd 2025-06-03 21:49:13 +08:00
parent 65a1ea5a07
commit ad921d10a1
3 changed files with 11 additions and 5 deletions

View File

@ -46,7 +46,7 @@ export default {
this.downloadAvailable = false; this.downloadAvailable = false;
this.error = false; this.error = false;
this.fetching = true; this.fetching = true;
axios.get(`/download_api?videourl=${this.url}`).then((responce)=>{ axios.get(`/api/v1/video/download?videourl=${this.url}`).then((responce)=>{
this.fetching = false; this.fetching = false;
if (responce.data.error){ if (responce.data.error){
this.error = true; this.error = true;
@ -55,7 +55,7 @@ export default {
console.log(responce.data.error); console.log(responce.data.error);
} else if (responce.data.link){ } else if (responce.data.link){
this.downloadAvailable = true; this.downloadAvailable = true;
this.downloadLink = `/download/${responce.data.link}`; this.downloadLink = `/api/v1/file/download/${responce.data.link}`;
} }
}).catch((error)=>{ }).catch((error)=>{
this.fetching = false; this.fetching = false;

View File

@ -17,3 +17,12 @@ use Illuminate\Support\Facades\Route;
Route::middleware('auth:sanctum')->get('/user', function (Request $request) { Route::middleware('auth:sanctum')->get('/user', function (Request $request) {
return $request->user(); return $request->user();
}); });
Route::group(['prefix' => 'v1'], function () {
Route::group(['prefix' => 'video'], function () {
Route::get('/download', 'App\Http\Controllers\YoutubeDownloadController@index');
});
Route::group(['prefix' => 'file'], function () {
Route::get('/download/{file}', 'App\Http\Controllers\DownloadController@download')->name('download');
});
});

View File

@ -16,6 +16,3 @@ use Illuminate\Support\Facades\Route;
Route::get('/', function () { Route::get('/', function () {
return view('welcome'); return view('welcome');
}); });
Route::get('/download_api', 'App\Http\Controllers\YoutubeDownloadController@index');
Route::get('/download/{file}', 'App\Http\Controllers\DownloadController@download')->name('download');