开发者

Unable to Write Print Statement without CORS policy error? [closed]

Closed. This question needs debugging details. It is not currently accepting answers.

Edit the question to include desired behavior, a specific problem or error, and the shortest code necessary to reproduce the problem. This will help others answer the question.

Closed 11 hours ago.

Improve this question

I am trying to simply write a print statement inside my laravel function, however it is breaking my code giving the following error in my web app console:

Access to XMLHttpRequest at 'mysite' from origin 'local:4200' has been blocked by CORS policy: No 'Access-Control-Allow-Origin' header is present o开发者_JS百科n the requested resource.

The code runs fine without the print statement:

    public function create(UploadedFile $file, $path = '', int $integrationId = null, $virusScan = true)
    {
        if ($virusScan) {
            $this->validateFileWithAntivirus($file);
        }

        $fileExtension = $file->getClientOriginalExtension();
        $extension = FileExtension::firstOrCreate(['name' => $fileExtension]);
        
        /* LINE I would like to print */
        dd($extension);

        $destinationFilename = Helper::generateUuid();

        Storage::putFileAs(
            File::getFolderPath(),
            $file,
            $destinationFilename
        );

        $filename = pathinfo($file->getClientOriginalName(), PATHINFO_FILENAME);

        return File::create([
            'id' => $destinationFilename,
            File::FILENAME => Helper::removeTrailingSpaces($filename),
            'path' => $path,
            'file_extension_id' => $extension->id,
            'integration_id' => $integrationId,
            'created_by_id' => $this->getAuthUser()->id,
            'created_by_model_type' => get_class($this->getAuthUser())
        ])->loadMissing(['extension']);
    }

Please let me know what I am doing wrong.

Thanks!

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜