Shopify / Shopify/shopify-app-template-php

The CORS Issues

Open
#418 2 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
PHP
Stars
340
Forks
108
PR merge metrics
No merged PRs in 30d

Description

Issue summary

Can't make the CORS policy to work. I'm using a fresh install of the package. I've added this one fruitcake/laravel-cors to the project (which is working fine with a pure Laravel build). I've added a simple GET route /api/test and then made a fetch request from the Shopify store frontend to the route. Did I miss something?

Expected behavior

A request should go without CORS error returned.

Actual behavior

The cors middleware has been totally ignored. The request returns an error "Access to fetch at '{TARGETURL}' from origin '{ORIGINURL}' 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."

Headers of the Response
content-length: 1385
content-security-policy: default-src 'self' https://cdn.ngrok.com 'unsafe-eval' 'unsafe-inline'
content-type: text/html
date: Wed, 08 Feb 2023 21:46:20 GMT
ngrok-trace-id: 1760a8d470f1a0fc873743c7e8f6ab8f
referrer-policy: no-referrer
x-content-type-options: nosniff

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with the simple GET /api/test route and the configured CORS middleware in the fresh installation. Reproduce the fetch request from the Shopify store frontend and inspect the response headers and middleware path. Done means the request receives the expected Access-Control-Allow-Origin header without a CORS error.

Written by the indexing model from the issue text.

Assessment

Tech stack
laravel, php
Domain
api, backend
Issue type
Bug
Difficulty
2/5
Estimated time
1-3 hours
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.