You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I've been stuck for days now trying to get Laravel7 and Sanctum to work with docker and nginx.
It seems no matter what I try I get 401 unauthorized when I try an API route with a Vue SPA that contains an authenticated session cookie and csrf token.
I followed this tutorial except I'm using docker and nginx.
I'm starting to think that the problem has something to do with docker/nginx or maybe the version combination with Laravel7 and Sanctum libraries.
Any suggestions are greatly appreciated.
Here are some of my files:
Dockerfile.dev
FROM php:7.4.0-fpm
# Arguments defined in docker-compose.yml
ARG user
ARG uid
# Install system dependencies
RUN apt-get update && apt-get install -y \
git \
curl \
libpng-dev \
libonig-dev \
libxml2-dev \
zip \
unzip \
gnupg2 \
libzip-dev \
nano \
wget
# Clear cache
RUN apt-get clean && rm -rf /var/lib/apt/lists/*
# Install PHP extensions
RUN docker-php-ext-install pdo_mysql mbstring exif pcntl bcmath gd zip
# Install XDebugLike
RUN yes | pecl install xdebug \
&& echo "zend_extension=$(find /usr/local/lib/php/extensions/ -name xdebug.so)" > /usr/local/etc/php/conf.d/xdebug.ini \
&& echo "xdebug.remote_enable=on" >> /usr/local/etc/php/conf.d/xdebug.ini \
&& echo "xdebug.remote_connect_back=0" >> /usr/local/etc/php/conf.d/xdebug.ini \
&& echo "xdebug.remote_port=9090" >> /usr/local/etc/php/conf.d/xdebug.ini \
&& echo "xdebug.remote_host=host.docker.internal" >> /usr/local/etc/php/conf.d/xdebug.ini \
&& echo "xdebug.var_display_max_depth=5" >> /usr/local/etc/php/conf.d/xdebug.ini \
&& echo "xdebug.var_display_max_children=256" >> /usr/local/etc/php/conf.d/xdebug.ini \
&& echo "xdebug.var_display_max_data = 1024" >> /usr/local/etc/php/conf.d/xdebug.ini \
&& echo "xdebug.remote_log=/var/www/xdebug.log" >> /usr/local/etc/php/conf.d/xdebug.ini \
&& echo "xdebug.idekey=VSCODE" >> /usr/local/etc/php/conf.d/xdebug.ini \
&& echo "xdebug.remote_autostart=on" >> /usr/local/etc/php/conf.d/xdebug.ini
# Use the default development configuration
# RUN mv "$PHP_INI_DIR/php.ini-development" "$PHP_INI_DIR/php.ini"
# Get latest Composer
COPY --from=composer:latest /usr/bin/composer /usr/bin/composer
# Create system user to run Composer and Artisan Commands
RUN useradd -G www-data,root -u $uid -d /home/$user $user
RUN mkdir -p /home/$user/.composer && \
chown -R $user:$user /home/$user
# replace shell with bash so we can source files
RUN rm /bin/sh && ln -s /bin/bash /bin/sh
# update the repository sources list
# and install dependencies
RUN apt-get update \
&& apt-get install -y curl \
&& apt-get -y autoclean
# Set working directory
WORKDIR /var/www
RUN chown -R $user:$user /var/www
COPY --chown=$user:$user . .
# xdebug
EXPOSE 9090
USER $user
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
I've been stuck for days now trying to get Laravel7 and Sanctum to work with docker and nginx.
It seems no matter what I try I get 401 unauthorized when I try an API route with a Vue SPA that contains an authenticated session cookie and csrf token.
I followed this tutorial except I'm using docker and nginx.
I'm starting to think that the problem has something to do with docker/nginx or maybe the version combination with Laravel7 and Sanctum libraries.
Any suggestions are greatly appreciated.
Here are some of my files:
Dockerfile.dev
docker-compose.yml
docker-compose.override.yml
nginx config
composer.json
Beta Was this translation helpful? Give feedback.
All reactions