作者热门文章
- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我一直在尝试解决仅在生产中发生的错误。当我尝试 create
一个新的数据库条目,抛出以下错误:
Mixed Content: The page at 'https://strong-moebel.art/admin/gallerie/neu' was loaded over HTTPS, but requested an insecure XMLHttpRequest endpoint 'http://strong-moebel.art/admin/gallerie'. This request has been blocked; the content must be served over HTTPS.
Uncaught (in promise) Error: Network Error
at wh (main.750d1ea1.js:4:96980)
at s.onerror (main.750d1ea1.js:5:1837)
其他一切正常,包括
edit
条目的方法。我正在使用
resource controller
.
create
方法使用惯性的
form.post
和
edit
方法使用它的
form.put
(如果这是相关的)。
if (App::environment('production')) {
URL::forceScheme('https');
}
到
boot()
你的方法
AppServiceProvider.php
.我已经这样做了,但错误仍然存在。我想知道这是否是一个惯性问题。
APP_ENV=production
APP_URL=http://localhost
APP_URL=https://localhost
APP_URL=
APP_URL=http://strong-moebel.art
APP_URL=https://strong-moebel.art
但似乎没有什么能解决这个问题。我的虚拟主机是 cloudways,我正在使用他们的
Let's Encrypt SSL Certificate
.我也尝试删除证书并查看会发生什么,但即便如此,也会发生完全相同的错误。我对
SSL
的教育程度不高并且想知道是否有人可以帮助我解决问题或指出我可以调查的事情。
vite
建生产建。
form.post
发送请求的组件:
<template layout="backend/cms-layout">
<div id="cms-gallery-create" class="cms-gallery-create">
<form @submit.prevent="storeRecord" method="post" enctype="multipart/form-data">
<div class="title-btn-bar">
<h1>Erstelle eine Kreation:</h1>
<input type="submit" class="btn" value="Kreation speichern">
</div>
<p>Titel:</p>
<input class="textfield-closed title-field" v-model="form.title">
<p>Titelbild:</p>
<cms-img-upload v-model:image="form.image"/>
<p>Hauptteil:</p>
<cms-custom-editor v-model="form.body"/>
</form>
<div v-if="errors.target" class="error">{{ errors.target }}</div>
</div>
</template>
<script setup>
import CmsImgUpload from '../../components/backend/cms-img-upload.vue'
import CmsCustomEditor from '../../components/backend/cms-custom-editor.vue'
import {useForm} from "@inertiajs/inertia-vue3";
const props = defineProps({
errors: Object
})
const form = useForm({
title: '',
body: '',
image: '',
})
const storeRecord = () => {
form.post('/admin/gallerie/')
}
</script>
然后由
inertia
路由到后端->
web.php
:
Route::middleware('auth')->group(function() {
Route::inertia('/admin/dashboard', 'backend/cms-dashboard');
Route::post('/admin/gallerie/move', [GalleryController::class, 'moveRow']);
Route::resource('/admin/gallerie', GalleryController::class);
Route::post('/admin/verkauf/move', [ShopController::class, 'moveRow']);
Route::resource('/admin/verkauf', ShopController::class);
Route::post('/admin/logout', [LoginController::class, 'destroy']);
});
并发送至
resource controller
通过:
Route::resource('/admin/gallerie', GalleryController::class);
在 Controller 内部,调用此方法将请求数据存储在数据库中:
public function store(Request $request)
{
if ($request->image) {
$image_path = Custom::storeBase64Image($this->STORAGE_PATH, $request);
} else {
$image_path = null;
}
Gallery::create([
'title' => $request->title,
'body' => $request->body,
'image_path' => $image_path
]);
return redirect($this->BASE_URL);
}
问题似乎发生在前端,因为没有
logs
创建的。
最佳答案
感谢@PaulTsai,它现在可以工作了。我不得不改变:
form.post('/admin/gallerie/')
至:
form.post('/admin/gallerie')
关于laravel - 混合内容 : The page at 'domain' was loaded over HTTPS, 但请求了不安全的 XMLHttpRequest 端点,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/72590500/
我是一名优秀的程序员,十分优秀!