我正在构建一个Shopify应用程序。我想添加application proxy。一切正常 - 本地路径导致重定向到我的页面。
但是,如果我设置Content-Type: application/liquid
标题,页面应作为本地Shopify页面加载。
但是当我这样做时,浏览器只是下载输出而不是在Shopify主题的上下文中显示它。
任何想法我做错了什么或可能导致什么?
来自Shopify文档:
如果来自代理URL的HTTP响应具有Content-Type: 应用/液体设置在其标题中,Shopify将评估和 在请求的上下文中呈现任何Liquid代码 使用商店的主题购物。当以正确的方式使用时,它可以 自动使您的应用看起来像属于商店的一部分 没有任何人工干预。
更新
它似乎在一台服务器上工作正常,但继续在另一台服务器上下载。到目前为止,试图比较标题没有运气。
答案 0 :(得分:3)
我有同样的问题。经过数小时的故障排除后,我发现这是我的.htaccess文件中的一个指令导致了这个问题。这就是以前的样子:
# Redirect Trailing Slashes...
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^(.*)/$ /$1 [L,R=301]
当我将其更改为下面时,代理页面正确呈现:
(http://proguard.sourceforge.net/manual/troubleshooting.html#duplicateclass)
Warning: can't write resource [.gitkeep] (Duplicate zip entry [DMMPlaybackBitrateSwitching-1.0.jar:.gitkeep])
...
Warning: can't write resource [.gitkeep] (Duplicate zip entry [DMMDigitalMusicLocatorServiceClient-1.0.jar:.gitkeep])
Exception while processing task
java.io.IOException: Can't write [/Users/fruitman/dev/MusicAndroid-one/build/DigitalMusicAndroidAppOne/DigitalMusicAndroidAppOne-11.0/RHEL5_64/DEV.STD.PTHREAD/build/private/android-gradle/intermediates/classes-proguard/fourfireOS/debug/classes.jar] (Can't read [/Users/fruitman/dev/MusicAndroid-one/build/DigitalMusicAndroidAppOne/DigitalMusicAndroidAppOne-11.0/RHEL5_64/DEV.STD.PTHREAD/build/private/tmp/artifacts/multidex.jar(;;;;;;!META-INF/MANIFEST.MF)] (Duplicate zip entry [multidex.jar:android/support/multidex/MultiDex$V14.class]))
at proguard.OutputWriter.writeOutput(OutputWriter.java:187)
at proguard.OutputWriter.execute(OutputWriter.java:79)
at proguard.ProGuard.writeOutput(ProGuard.java:427)
at proguard.ProGuard.execute(ProGuard.java:175)
at proguard.gradle.ProGuardTask.proguard(ProGuardTask.java:1074)
at com.android.build.gradle.tasks.AndroidProGuardTask.doMinification(AndroidProGuardTask.java:139)
at com.android.build.gradle.tasks.AndroidProGuardTask$1.run(AndroidProGuardTask.java:115)
at com.android.builder.tasks.Job.runTask(Job.java:48)
at com.android.build.gradle.tasks.SimpleWorkQueue$EmptyThreadContext.runTask(SimpleWorkQueue.java:41)
at com.android.builder.tasks.WorkQueue.run(WorkQueue.java:227)
at java.lang.Thread.run(Thread.java:745)
Caused by: java.io.IOException: Cannot read [/Users/fruitman/dev/MusicAndroid-one/build/DigitalMusicAndroidAppOne/DigitalMusicAndroidAppOne-11.0/RHEL5_64/DEV.STD.PTHREAD/build/private/tmp/artifacts/multidex.jar(;;;;;;!META-INF/MANIFEST.MF)] (Duplicate zip entry [multidex.jar:android/support/multidex/MultiDex$V14.class])
at proguard.InputReader.readInput(InputReader.java:188)
at proguard.InputReader.readInput(InputReader.java:158)
at proguard.OutputWriter.writeOutput(OutputWriter.java:176)
... 10 more
Caused by: java.io.IOException: Duplicate zip entry [multidex.jar:android/support/multidex/MultiDex$V14.class]
at proguard.io.JarWriter.getOutputStream(JarWriter.java:138)
at proguard.io.FilteredDataEntryWriter.getOutputStream(FilteredDataEntryWriter.java:105)
at proguard.io.FilteredDataEntryWriter.getOutputStream(FilteredDataEntryWriter.java:105)
at proguard.io.FilteredDataEntryWriter.getOutputStream(FilteredDataEntryWriter.java:92)
at proguard.io.ClassRewriter.read(ClassRewriter.java:68)
at proguard.io.FilteredDataEntryReader.read(FilteredDataEntryReader.java:87)
at proguard.io.FilteredDataEntryReader.read(FilteredDataEntryReader.java:87)
at proguard.io.FilteredDataEntryReader.read(FilteredDataEntryReader.java:87)
at proguard.io.JarReader.read(JarReader.java:65)
at proguard.io.DirectoryPump.readFiles(DirectoryPump.java:65)
at proguard.io.DirectoryPump.pumpDataEntries(DirectoryPump.java:53)
at proguard.InputReader.readInput(InputReader.java:184)
... 12 more
:DigitalMusicAndroidAppOne:shrinkFourFireOSDebugMultiDexComponents FAILED
FAILURE: Build failed with an exception.
* What went wrong:
Execution failed for task ':DigitalMusicAndroidAppOne:shrinkFourFireOSDebugMultiDexComponents'.
> java.io.IOException: Can't read [/Users/fruitman/dev/MusicAndroid-one/build/DigitalMusicAndroidAppOne/DigitalMusicAndroidAppOne-11.0/RHEL5_64/DEV.STD.PTHREAD/build/private/android-gradle/intermediates/classes-proguard/fourfireOS/debug/classes.jar] (Can't process class [com/company/communication/ir/ParcelableIRServiceEndpoint.class] (Unexpected end of ZLIB input stream))
* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output.
BUILD FAILED
Total time: 47.07 secs
BUILD FAILED
另请注意,如果您未请求文件(例如:proxy.php),但使用目录(例如:http://yourdomain.com/proxy),则对服务器的请求包含尾部斜杠(表示Shopify的代理请求http://yourdomain.com/proxy/)。 htaccess文件发出301重定向,这迫使Shopify下载文件而不是将其解释为液体。要解决该问题,您可以添加另一个重写条件,将这些域排除在重定向到theire" non-trailing-slash"对应。