小编Vir*_*irb的帖子

在提取API中启用CORS

我收到以下错误消息,我无法继续

无法加载https://site/data.json:对预检请求的响应未通过访问控制检查:所请求的资源上没有'Access-Control-Allow-Origin'标头。因此,不允许访问源' http:// localhost:8080 '。如果不透明的响应满足您的需求,请将请求的模式设置为“ no-cors”,以在禁用CORS的情况下获取资源。localhost /:1未捕获(承诺)TypeError:无法获取

我正在尝试CORS在我的react js文件中启用,但无法获得预期的结果。我已经安装了chrome扩展程序,并且可以正常工作。但是要在生产站点中使用它,我需要在代码中启用它。我应该如何正确安排代码以启用CORS。

fetch(URL, {
  mode: 'cors',
  headers: {
    'Access-Control-Allow-Origin':'*'
  }
})
  .then(response => response.json())
  .then(data => {
Run Code Online (Sandbox Code Playgroud)

javascript reactjs fetch-api

13
推荐指数
1
解决办法
6万
查看次数

Rails Web 控制台未显示在运行时错误页面上

在开发环境中,当我将<%= console %>放入任何页面时,Web 控制台工作正常。但是,不要显示在运行时错误页面上。

没有网络控制台的错误页面:

带有 Web 控制台的页面:

我在用着:

  • 轨道 5.1.6
  • 红宝石2.5.1
  • 网络控制台-3.6.1

我的宝石文件:

source 'https://rubygems.org'

git_source(:github) do |repo_name|
  repo_name = "#{repo_name}/#{repo_name}" unless repo_name.include?("/")
  "https://github.com/#{repo_name}.git"
end


# Bundle edge Rails instead: gem 'rails', github: 'rails/rails'
gem 'rails', '~> 5.1.6'
# Use postgresql as the database for Active Record
gem 'pg', '>= 0.18', '< 2.0'

gem 'devise'
gem 'milia', '~>1.3'
gem 'twitter-bootstrap-rails'
gem 'devise-bootstrap-views'
gem 'bootstrap-datepicker-rails'
# Use Puma as the app server
gem 'puma', '~> 3.7'
# Use SCSS …
Run Code Online (Sandbox Code Playgroud)

ruby-on-rails

3
推荐指数
1
解决办法
1261
查看次数

How to fix: The difference between the request time and the current time is too large

I receive this error from AWS:

App\Services\Exceptions\Exception thrown with message "Error in updated facebook event in the systemError executing "PutObject" on "n.jpg"; AWS HTTP error: Client error: PUT n.jpg resulted in a 403 Forbidden response: RequestTimeTooSkewedThe difference between the reque (truncated...) RequestTimeTooSkewed (client): The difference between the request time and the current time is too large. - RequestTimeTooSkewedThe difference between the request time and the current time is too large.20180403T075710Z2018-04-03T06:57:48Z900000"

It says request time is: 7:57 am and …

php timezone amazon-s3 amazon-web-services laravel

2
推荐指数
2
解决办法
9299
查看次数

未定义的变量php laravel 5.4

我一直遇到同样的错误,

未定义的变量:我的刀片上的影院,第14行。

这是我的addcine.blade.php第14行

@foreach ($theaters as $theater)
    <option value="{{ $theater->name }}"/>
    @endforeach
Run Code Online (Sandbox Code Playgroud)

这是我的addcinemacontroller

public function index(){

$theaters = Theater::all();

return view('schedules.addcine', compact('name'));
Run Code Online (Sandbox Code Playgroud)

和我的路线

Route::get('addcinema','AddCinemaController@index');
});
Run Code Online (Sandbox Code Playgroud)

php laravel

1
推荐指数
1
解决办法
671
查看次数

在laravel中显示平均评级的用户详细信息

在我的情况下,我有两个表像用户表和评级表.

在用户表中,我存储用户的个人详细信息,如姓名,电子邮件等,

在评级表中,我存储了user_id和评级(评级将是1,2,3,4和5之类的数字)

我创建了关系,这里有两个表是关系

//User Model
public function ratings()
{
    return $this->hasMany(Rating::class);
}

//Rating model
public function user()
{
    return $this->belongsTo(Consultant::class);
}
Run Code Online (Sandbox Code Playgroud)

我能够以急切的加载方式显示获取数据

 $data = User::with('ratings')->get();
Run Code Online (Sandbox Code Playgroud)

我从急切的负载得到的响应是

 [
 {
 "id": 1,
 "cunsultant_name": "Quincy Jerde",
 "contact_number": "882-904-3379",
    "ratings": [
    {

        "user_id": 1,
        "rating_for_user": 3

    },
    {

        "user_id": 1,
        "rating_for_user": 5
    },
    {

        "user_id": 2,
        "rating_for_user": 3
    }
    ]
    },
    {
   "user_name": "Alene Dicki",
   "contact_number": "247.604.8170",
        "ratings": [
            {
                "id": 4,
                "user_id": 3, …
Run Code Online (Sandbox Code Playgroud)

php laravel laravel-5 laravel-5.3 laravel-5.4

1
推荐指数
1
解决办法
2186
查看次数

使用图片上传查找相似图片

在这里,我想通过上传图像从 MySQL 中搜索图像。我已经尝试过hash和rgb,也尝试过hex。但我没有像谷歌那样得到完美的图片。例如,如果您找到了Koala.jpg,那么您只能看到与 相关的那些照片Koala.jpg。但是我也通过上述尝试获得了其他照片。是否有任何建议我可以通过图像上传从数据库中搜索图像。提前致谢。

php google-image-search

0
推荐指数
1
解决办法
3873
查看次数