I want to have the back-end and front-end of my website separated. For the front-end i am using Angular. For the backend i am using Symfony.
To run everything i use Docker from php:7.1.8-apache
The back-end does run, and i can access it from http://localhost:8080/api/
I have looked in internet for things, and tried a lot of them that would suite me. But it did not work.
I tried to make a .htaccess and set this code in it:
RewriteEngine On
RewriteCond %{REQUEST_URI} ^/api
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^ core/public/
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^ spa/dist/spa/
Docker: docker-compose.yml:
version: '3'
services:
app:
build:
context: .
dockerfile: .docker/Dockerfile
image: meeting-rooms-docker
ports:
- 8080:80
volumes:
- .:/srv/app
Dockerfile:
FROM php:7.1.8-apache
MAINTAINER Joey
COPY . /srv/app
COPY .docker/vhost.conf /etc/apache2/sites-available/000-default.conf
RUN chown -R www-data:www-data /srv/app \
&& a2enmod rewrite
vhost.conf
<VirtualHost *:80>
DocumentRoot /srv/app/
<Directory "/srv/app/">
AllowOverride all
Require all granted
</Directory>
ErrorLog ${APACHE_LOG_DIR}/error.log
CustomLog ${APACHE_LOG_DIR}/access.log combined
</VirtualHost>
my file structure:
projectFile
- spa (Angular)
- Core (Symfony)
- .docker
.htaccess
when i use the command ng serve
in the spa folder. It shows the right page (the welcome page).
But when i go to the page that is run with docker and is going true the .htaccess it shows this error:
Failed to load module script: The server responded with a non-JavaScript MIME type of "text/html". Strict MIME type checking is enforced for module scripts per HTML spec.
in the console