在vue和laravel之间的请求资源上不存在“ Access-Control-Allow-Origin”标头

时间:2018-11-19 10:43:56

标签: laravel vue.js

你好,我使用axios从Vuejs向Laravel后端发出GET请求。 Laravel API返回博客。当有4个博客且超过4个博客时,这没问题,错误变为并且没有数据发送。错误的屏幕截图是 please click here

这是我的JS代码

@Entity
@Table(name = "social_profile")
public class SocialProfile implements java.io.Serializable {

    @EmbeddedId
    private SocialProfileId id;

    @Column(name="email")
    private String email;
}

这是我的Laravel内核

    axios.get(url)
    .then((response)=>{
      payload.context.rootState.Misc.pre_loading=false;
      callback(response.data);
    }).catch(error => {


      alert("Server error");
      console.log(error)
  });

这是我的cors.php

    protected $middleware = [
        \App\Http\Middleware\CheckForMaintenanceMode::class,
        \Illuminate\Foundation\Http\Middleware\ValidatePostSize::class,
        \App\Http\Middleware\TrimStrings::class,
        \Illuminate\Foundation\Http\Middleware\ConvertEmptyStringsToNull::class,
        \App\Http\Middleware\TrustProxies::class,
        \Barryvdh\Cors\HandleCors::class,
    ];

/**
 * The application's route middleware groups.
 *
 * @var array
 */
protected $middlewareGroups = [
    'web' => [
        \App\Http\Middleware\EncryptCookies::class,
        \Illuminate\Cookie\Middleware\AddQueuedCookiesToResponse::class,
        \Illuminate\Session\Middleware\StartSession::class,
        // \Illuminate\Session\Middleware\AuthenticateSession::class,
        \Illuminate\View\Middleware\ShareErrorsFromSession::class,
        \App\Http\Middleware\VerifyCsrfToken::class,
        \Illuminate\Routing\Middleware\SubstituteBindings::class,
    ],

    'api' => [
        'throttle:60,1',
        'bindings',
        \Barryvdh\Cors\HandleCors::class,
    ],
];

请帮助我。我不知道怎么了。

Here is the screenshot for headers. Data are shown in this preview tag of network.

header's screenshot the response data in the network tag

0 个答案:

没有答案