skip to Main Content

I have created a new app using the Shopify App Template for PHP (https://github.com/Shopify/shopify-app-template-php).

When I run npm run dev the app works fine in my local development environment.

However, when I try to deploy the app to a server and run npm run build --api-key=MY_API_KEY I encounter the following error:

"Building the frontend app without an API key. The frontend build will not run without an API key. Set the SHOPIFY_API_KEY environment variable when running the build command."

To resolve this issue, I tried running the build command with the environment variable set as follows:
SHOPIFY_API_KEY=MY_API_KEY npm run build

This successfully addressed the API key error.

However, now when I attempt to install my app on a development store, the installation flow redirects to the React page I built, but then redirects back to Shopify with a 404 error. It seems that the authentication, app installation, and recurring charge steps are being missed.

Can you please help what am I missing?

Thank you.

2

Answers


  1. This is to do with the existence of index.html in the public directory after running composer build in the web directory.

    in your nginx/apache config you probably have something like
    index index.html index.htm index.php;

    change this to be in alignment with the recommendation from the supplied nginx.conf in the repository.

    index index.php index.html index.htm;

    Login or Signup to reply.
  2. I have the same problem and I fixed it with your answer however when trying to query the domain in which the application was configured now it mentions that the host argument does not exist and that the application cannot be used

    Missing host query argument
    Please ensure that it is set, or access your app using the Partners Dashboard Test your app feature

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search