remove api prefix from routes (#280)

* remove api prefix from routes

* PR changes

---------

Co-authored-by: Julien Nahum <julien@nahum.net>
This commit is contained in:
formsdev 2024-01-12 22:05:16 +05:30 committed by GitHub
parent be43c5cae3
commit 57ce0e6114
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
13 changed files with 47 additions and 79 deletions

View File

@ -1,18 +0,0 @@
<?php
namespace App\Http\Controllers;
use App\Service\SeoMetaResolver;
use Illuminate\Http\Request;
class SpaController extends Controller
{
/**
* Get the SPA view.
*/
public function __invoke(Request $request)
{
return view('spa',[
'meta' => (new SeoMetaResolver($request))->getMetas(),
]);
}
}

View File

@ -40,18 +40,13 @@ class RouteServiceProvider extends ServiceProvider
$this->routes(function () {
Route::prefix('api')
->middleware('api')
Route::middleware('api')
->namespace($this->namespace)
->group(base_path('routes/api.php'));
Route::middleware('web')
->namespace($this->namespace)
->group(base_path('routes/web.php'));
Route::middleware('spa')
->namespace($this->namespace)
->group(base_path('routes/spa.php'));
});
}

View File

@ -101,7 +101,8 @@ export default {
setup () {
const workingFormStore = useWorkingFormStore()
return {
workingFormStore
workingFormStore,
runtimeConfig: useRuntimeConfig()
}
},
@ -134,7 +135,7 @@ export default {
if (!this.form) {
return ''
}
return '/api/open/forms/' + this.form.id + '/submissions/export'
return this.runtimeConfig.public.apiBase + '/open/forms/' + this.form.id + '/submissions/export'
},
filteredData () {
if (!this.tableData) return []

View File

@ -64,7 +64,7 @@
}),
methods: {
async send () {
const { data } = await this.form.post('/api/password/email')
const { data } = await this.form.post('/password/email')
this.isMailSent = true
},
close () {

View File

@ -120,7 +120,7 @@ export default {
if (this.loading) return
this.loading = true
this.aiForm.post('/api/forms/ai/generate').then(response => {
this.aiForm.post('/forms/ai/generate').then(response => {
this.useAlert.success(response.data.message)
this.fetchGeneratedForm(response.data.ai_form_completion_id)
}).catch(error => {

View File

@ -95,7 +95,7 @@ export default {
}),
computed: {
formEndpoint: () => '/api/open/forms/{id}',
formEndpoint: () => '/open/forms/{id}',
},
methods: {

View File

@ -42,7 +42,7 @@ export default {
methods: {
async send () {
const { data } = await this.form.post('/api/password/email')
const { data } = await this.form.post('/password/email')
this.status = data.status

View File

@ -60,7 +60,7 @@ export default {
methods: {
async reset () {
const { data } = await this.form.post('/api/password/reset')
const { data } = await this.form.post('/password/reset')
this.status = data.status

View File

@ -8,12 +8,12 @@
Tools
</h3>
<div class="flex flex-wrap mb-5">
<a href="/stats">
<a :href="statsUrl" target="_blank">
<v-button class="mx-1" color="gray" shade="lighter">
Stats
</v-button>
</a>
<a href="/horizon">
<a :href="horizonUrl" target="_blank">
<v-button class="mx-1" color="gray" shade="lighter">
Horizon
</v-button>
@ -53,6 +53,10 @@ let form = useForm({
})
let loading = false
const runtimeConfig = useRuntimeConfig()
const statsUrl = runtimeConfig.public.apiBase + '/stats'
const horizonUrl = runtimeConfig.public.apiBase + '/horizon'
const impersonate = () => {
loading = true
authStore.startImpersonating()

View File

@ -15,7 +15,7 @@ return [
|
*/
'paths' => ['api/*'],
'paths' => ['*'],
'allowed_methods' => ['*'],

View File

@ -18,6 +18,9 @@ use App\Http\Controllers\Forms\RecordController;
use App\Http\Controllers\WorkspaceController;
use App\Http\Controllers\TemplateController;
use App\Http\Controllers\Forms\Integration\FormZapierWebhookController;
use Illuminate\Http\Request;
use Illuminate\Http\Response;
use Illuminate\Support\Facades\Storage;
use Illuminate\Support\Facades\Route;
/*
@ -177,3 +180,31 @@ Route::prefix('templates')->group(function () {
Route::put('/{id}', [TemplateController::class, 'update'])->name('templates.update');
Route::delete('/{id}', [TemplateController::class, 'destroy'])->name('templates.destroy');
});
Route::post(
'/stripe/webhook',
[\App\Http\Controllers\Webhook\StripeController::class, 'handleWebhook']
)->name('cashier.webhook');
Route::post(
'/vapor/signed-storage-url',
[\App\Http\Controllers\Content\SignedStorageUrlController::class, 'store']
)->middleware([]);
Route::post(
'/upload-file',
[\App\Http\Controllers\Content\FileUploadController::class, 'upload']
)->middleware([]);
Route::get('local/temp/{path}', function (Request $request, string $path){
if (!$request->hasValidSignature()) {
abort(401);
}
$response = Response::make(Storage::get($path), 200);
$response->header("Content-Type", Storage::mimeType($path));
return $response;
})->where('path', '(.*)')->name('local.temp');
Route::get('caddy/ask-certificate/{secret?}', [\App\Http\Controllers\CaddyController::class, 'ask'])
->name('caddy.ask')->middleware(\App\Http\Middleware\CaddyRequestMiddleware::class);

View File

@ -1,17 +0,0 @@
<?php
use App\Http\Controllers\SpaController;
use Illuminate\Support\Facades\Route;
/*
|--------------------------------------------------------------------------
| SPA Routes
|--------------------------------------------------------------------------
|
| Here is where you can register SPA routes for your frontend. These
| routes are loaded by the RouteServiceProvider within a group which
| is assigned the "spa" middleware group.
|
*/
Route::get('{path}', SpaController::class)->where('path', '^(?!(api|stats|mailcoach|vapor|sitemap|caddy|dist)).*$');

View File

@ -1,8 +1,6 @@
<?php
use Illuminate\Support\Facades\Route;
use Illuminate\Support\Facades\Storage;
use Illuminate\Http\Request;
/*
|--------------------------------------------------------------------------
@ -14,29 +12,3 @@ use Illuminate\Http\Request;
| contains the "web" middleware group. Now create something great!
|
*/
Route::post(
'/stripe/webhook',
[\App\Http\Controllers\Webhook\StripeController::class, 'handleWebhook']
)->name('cashier.webhook');
Route::post(
'/vapor/signed-storage-url',
[\App\Http\Controllers\Content\SignedStorageUrlController::class, 'store']
)->middleware([]);
Route::post(
'/upload-file',
[\App\Http\Controllers\Content\FileUploadController::class, 'upload']
)->middleware([]);
Route::get('local/temp/{path}', function (Request $request, string $path){
if (!$request->hasValidSignature()) {
abort(401);
}
$response = Response::make(Storage::get($path), 200);
$response->header("Content-Type", Storage::mimeType($path));
return $response;
})->where('path', '(.*)')->name('local.temp');
Route::get('caddy/ask-certificate/{secret?}', [\App\Http\Controllers\CaddyController::class, 'ask'])
->name('caddy.ask')->middleware(\App\Http\Middleware\CaddyRequestMiddleware::class);