我在本地的 Mac 上开发。大苏尔的最新版本。
今天,我通过 Forge 通过 Ubuntu 服务器将我的应用程序部署到生产环境中,但遇到了一个我以前从未见过的错误,并且无法在网上找到答案。我可以看到很多人在抱怨它,但是任何人在其他答案中所说的都是指向没有解决方案甚至没有解释的问题的链接,所以这就是我提出一个新问题的原因。
确切的错误是这样的;
Unable to locate a class or view for component [layouts.base]. (View: /home/forge/default/releases/20201204084441/resources/views/layouts/app.blade.php)
在我的应用程序中,我有;
app\View\Components\Layouts\App.php
看起来像这样;
<?php
namespace App\View\Components\Layouts;
use Illuminate\View\Component;
class App extends Component
{
public function render()
{
return view('layouts.app');
}
}
Run Code Online (Sandbox Code Playgroud)
那我也有;
resources\views\layouts\app.blade.php
<x-layouts.base>
<!-- contents -->
</x-layouts.base>
Run Code Online (Sandbox Code Playgroud)
(也几乎相同的基础)
在 Mac 上完美运行。一旦我在 Ubuntu 上部署它,我就会收到上面的错误,即“无法找到具有这些名称的类或视图”。
有人可以指导我如何解决这个问题,因为到目前为止我完全不知道,尽管知道区分大小写可能是其他问题的问题,但我找不到任何实际的解决方案或方法来解决这个。
因此,我将图像存储在名为“图像”的子目录中的公共文件夹中,并且我正尝试向其中之一发出请求。
但是,我不断收到错误;
Access to fetch at 'http://project.test/images/4obrUhRprw6CXSHsHEGEf4Gje2baKoiS7PQJvS4F.jpeg' from origin 'http://localhost:8080' has been blocked by CORS policy: No 'Access-Control-Allow-Origin' header is present on the requested resource. If an opaque response serves your needs, set the request's mode to 'no-cors' to fetch the resource with CORS disabled.
Run Code Online (Sandbox Code Playgroud)
我认为这是因为我使用 VueJS 作为 SPA 前端,就好像我前往project.test
并使请求正常工作一样。
我正在使用 laravel-cors,但经过一些研究,我发现这显然不适用于 public 文件夹,所以我尝试在 public 中使用 .htaccess 文件,这就是我所拥有的;
<IfModule mod_rewrite.c>
<IfModule mod_negotiation.c>
Options -MultiViews -Indexes
</IfModule>
<IfModule mod_headers.c>
SetEnvIf Origin "http(s)?://([^.]+\.)?(localhost:8080)$" AccessControlAllowOrigin=$0$1
Header add Access-Control-Allow-Origin %{AccessControlAllowOrigin}e env=AccessControlAllowOrigin
Header …
Run Code Online (Sandbox Code Playgroud) 我已经使用 Laravel Fortify 为我的应用程序编写了一些身份验证,并且我已经设置了 2FA 的启用部分,一切正常,但我遇到的问题是,当用户登录?
我已经像这样设置了自定义视图;
Fortify::twoFactorChallengeView(function () {
return view('auth.two-factor-challenge');
});
Run Code Online (Sandbox Code Playgroud)
Fortify 声称它应该“...自动将用户重定向到应用程序的两因素身份验证质询屏幕。” (https://laravel.com/docs/9.x/fortify#authenticating-with-two-factor-authentication),但对我来说情况并非如此,它根本不重定向。
似乎无法在源代码中找到任何类型的中间件来手动实现此目的,所以想知道是否有人知道发生了什么?
我已经手动检查了我的数据库,并且所有两个因子列two_factor_secret
在启用后都设置正确,所以我有点困惑。
在我的 fortify 配置中,我进行了以下设置,因为我不想确认密码,而是确认当前的 OTP 代码以进行任何需要进行的更改,因为我认为这对我的应用程序最有意义。不确定禁用是否confirmPassword
会导致这种情况?
Features::twoFactorAuthentication([
'confirm' => true,
'confirmPassword' => false,
]),
Run Code Online (Sandbox Code Playgroud) 我正在执行这样的查询以及其他一些查询,并通过response()->json()
.
$transactions = Transaction::where('created_at', '>=',
now()->firstOfYear())->get()->groupBy(function ($transaction)
{
return Carbon::parse($transaction->created_at)->format('M');
});
return response()->json([
'user' => $user->toArray(),
'transactions' => $transactions->toArray()
]);
Run Code Online (Sandbox Code Playgroud)
然而,虽然 transactions 在 php 中是一个数组,但当它通过 response()->json 时,它会变成一个对象。我希望有人能告诉我如何防止这种情况并将其保留为数组以便我可以迭代它?
谢谢。