Problem: Internal Server error when trying to proxy API calls from built ember app to production Node API, with .htaccess on CentOS with Apache.
Using Ember CLI 1.1.15
Enviroments.js file:
var ENV = {
modulePrefix: 'va-loans-frontend',
environment: environment,
baseURL: '/',
locationType: 'auto',
host: 'http://localhost:1337/api',
...
if (environment === 'production') {
ENV.host = "http://ift.tt/1q2ijpv";
}
.htaccess located in home/example/public_html
Options FollowSymLinks
RewriteEngine on
#redirect all page requests to main index
#RewriteCond %{REQUEST_URI} !^(index\.html|robots\.txt|img|font|js|css|scripts|action/.*) [NC]
RewriteRule ^api/ http://ift.tt/1Fus9Ux [P, L]
RewriteBase /
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^([^?]*)$ /index.html [NC,L,QSA]
#ProxyPassReverse /api http://ift.tt/1Fus9Ux
(RewriteCond
and ProxyPassReverse
being commented out is me just trying to simplify and rule out specific lines)
I've also tried using a virtual host with proxypass
rules and rewrite inside with no dice.
If I comment out the first RewriteRule ^api/*
then apache serves my ember app and even does page redirects correctly but none of my api calls work then as they all get redirected to index.html
.
My sails.js server is set to listen on port 8080 and is running in production mode with pm2. My built ember-cli project sits in my /public_html
folder and looks like so:
assets/, crossdomain.xml, .htaccess, index.html, robots.txt
.
Summery: Have apache serve index.html
(my built ember-cli app) and redirect any url requests that don't contain /api/
to index.html
so that ember can handle the routing. Any requests that do contain /api/
should be proxied to port 8080
where my sails.js node API lives and be handled there where it will eventually pass JSON back to my ember application.
Aucun commentaire:
Enregistrer un commentaire