intrithm's avatar

Sanctum On Multiple Domains

Hi ,

I've two Applicaion that are using same database. For file upload i created APIs in App A with sanctum middleware.when user logs in App B i will send the same username and password to App A and create sanctum token there.After i implemented google login i'm stuck with the problem that i can't create sanctum sesstions in App A. someone suggest me a solution for this or better way to approch this problem

0 likes
4 replies
Udev's avatar

Do they have same top level domain?

intrithm's avatar

@Udev app.truks.test - main application permit.truks.test - sub application both are using same database

Udev's avatar

@intrithm so you are using session auth for app A and token auth for app B?

Why not have Laravel backend "api.truks.test"

Then the two frontends "app.trucks.test" and "permit.trucks.test"

then in the .env

APP_URL=https://api.trucks.test
SANCTUM_STATEFUL_DOMAINS=app.trucks.test,permit.trucks.test
SESSION_DOMAIN=.trucks.test

then for gooogle auth use laravel socialite

intrithm's avatar

@Udev Actually app,permit are two different laravel applications using the same database im creating the tokens in permit and calls app API for file uploads. Tokens are working if i call login api and get token from there..if I manually generate token from permit and send requests it shows unauthorised. I made the changes in .env keep getting 401

Please or to participate in this conversation.