Shopify / koa-shopify-auth

DEPRECATED Middleware to authenticate a Koa application with Shopify
MIT License
80 stars 64 forks source link

Keeps redirecting to https://127.0.0.1:3000/auth/inline #84

Closed akhilmhdh closed 3 years ago

akhilmhdh commented 3 years ago

Issue summary

I have been following the node + react tutorial exactly. Added graphql and was working fine. But after sometime the app on restart keeps on redirecting to https://127.0.0.1:3000/auth/inline instead of my domain. Thought it was my mistake. But then again randomly when i restart it point back to my domain. Again same behaviour occurs.

Now oauth callback gets incomplete by redirecting to https://127.0.0.1:3000/auth/inline. As oauth is also getting failed when app loads internal server error occurs saying InternalServerError: Cannot complete OAuth process. Could not find an OAuth cookie for shop url:

Also I am using memory session storage as doc says but why cookie error. Getting so confused and frustrated, Have been looking through this two days. Sorry really don't know why this issue is happening. Would be really helpful to get some insight.

I would love to help you guys on some more proper real world documentation. Currently session and all the system is getting so confusing.

Expected behavior

Oauth should work properly.

Actual behavior

Redirects to https://127.0.0.1:3000/auth/inline and sometime fires InternalServerError: Cannot complete OAuth process. Could not find an OAuth cookie for shop url:

Checklist

ashraful19 commented 2 years ago

Hi @akhilmhdh How did you solved this issue ? i am facing the same problem. havent found a solution yet.

akhilmhdh commented 2 years ago

Hey there,

So the issue was actually in the server, more specifically the nginx infront of the server. I had to setup reverse proxy for smooth workflow. It was not actually an issue with shopify

ashraful19 commented 2 years ago

Hello @akhilmhdh Thank you so much replying. i am stuck into this issue for days, looking for the problem into shopify auth process. Good to know that it is a server problem. Is it possible for you to share the solution you applied ?

I have configured apache for reverse proxy, but the problem remains. My apache conf is below,


<IfModule mod_ssl.c>

 <VirtualHost *:80>
     ServerName myembeddedapp.com
     ServerAlias myembeddedapp.com
     DocumentRoot /var/www/html/embeddedapp
     ErrorLog ${APACHE_LOG_DIR}/error.log
     CustomLog ${APACHE_LOG_DIR}/access.log combined
     ProxyRequests On
     ProxyPass / http://localhost:8080/
     ProxyPassReverse / http://localhost:8080/
     Timeout 2400
     ProxyTimeout 2400
     ProxyBadHeader Ignore
 </VirtualHost>

<VirtualHost *:443>
    ServerName www.myembeddedapp.com
    ServerAlias myembeddedapp.com
    DocumentRoot /var/www/html/embeddedapp
    ErrorLog ${APACHE_LOG_DIR}/error.log
    CustomLog ${APACHE_LOG_DIR}/access.log combined
    SSLEngine on
    SSLCertificateFile      /etc/apache2/ssl-app/certificate.crt
    SSLCertificateKeyFile   /etc/apache2/ssl-app/server.key
    SSLCertificateChainFile /etc/apache2/ssl-app/ca_bundle.crt
    <FilesMatch "\.(cgi|shtml|phtml|php)$">
        SSLOptions +StdEnvVars
    </FilesMatch>
    <Directory /usr/lib/cgi-bin>
        SSLOptions +StdEnvVars
    </Directory>
    SSLProxyEngine on
    ProxyRequests On
    ProxyPass / http://localhost:8080/
    ProxyPassReverse / http://localhost:8080/
    Timeout 2400
    ProxyTimeout 2400
    ProxyBadHeader Ignore
</VirtualHost>

</IfModule>

Can you share your nginx conf file kindly ? would be really helpful. tomorrow i will try with nginx.