Skip to content

Instantly share code, notes, and snippets.

@royteusink
Last active December 31, 2020 13:21
Show Gist options
  • Save royteusink/62cbf3ef01216840851a9f85c0e2ec4e to your computer and use it in GitHub Desktop.
Save royteusink/62cbf3ef01216840851a9f85c0e2ec4e to your computer and use it in GitHub Desktop.

Revisions

  1. royteusink revised this gist Dec 31, 2020. 1 changed file with 21 additions and 1 deletion.
    22 changes: 21 additions & 1 deletion vue-sanctum.md
    Original file line number Diff line number Diff line change
    @@ -41,12 +41,32 @@ valet secure
    ```ini
    SANCTUM_STATEFUL_DOMAINS="app.yourdomain.test:8080"
    SESSION_DOMAIN=".yourdomain.test"
    SESSION_DRIVER=cookie
    SESSION_DRIVER=database
    SESSION_LIFETIME=120
    ```

    config/cors.php
    ```php
    'paths' => ['api/*', 'sanctum/csrf-cookie'],
    'supports_credentials' => true,
    ```

    logout route
    ```php
    public function logout(Request $request)
    {
    Auth::guard('web')->logout();

    $request->session()->flush();
    $request->session()->invalidate();
    $request->session()->regenerateToken();

    return response()->json(['message' => 'Successfully logged out'], 200);
    }
    ```

    session table
    ```bash
    php artisan session:table
    php artisan migrate
    ```
  2. royteusink revised this gist Dec 17, 2020. 1 changed file with 1 addition and 1 deletion.
    2 changes: 1 addition & 1 deletion vue-sanctum.md
    Original file line number Diff line number Diff line change
    @@ -1,4 +1,4 @@

    CORS issues with local development setup Laravel Sanctum with Vue3 cli

    ## app.yourdomain.test

  3. royteusink revised this gist Dec 17, 2020. 1 changed file with 8 additions and 0 deletions.
    8 changes: 8 additions & 0 deletions vue-sanctum.md
    Original file line number Diff line number Diff line change
    @@ -1,3 +1,5 @@


    ## app.yourdomain.test

    vue app created with vue cli.
    @@ -41,4 +43,10 @@ SANCTUM_STATEFUL_DOMAINS="app.yourdomain.test:8080"
    SESSION_DOMAIN=".yourdomain.test"
    SESSION_DRIVER=cookie
    SESSION_LIFETIME=120
    ```

    config/cors.php
    ```php
    'paths' => ['api/*', 'sanctum/csrf-cookie'],
    'supports_credentials' => true,
    ```
  4. royteusink revised this gist Dec 17, 2020. 1 changed file with 12 additions and 0 deletions.
    12 changes: 12 additions & 0 deletions vue-sanctum.md
    Original file line number Diff line number Diff line change
    @@ -2,6 +2,18 @@

    vue app created with vue cli.

    ```js
    axios.create({
    baseURL: process.env.VUE_APP_API_URL,
    withCredentials: true
    });
    ```

    .env
    ```ini
    VUE_APP_API_URL="https://api.yourdomain.test/"
    ```

    package.json
    ```
    {
  5. royteusink revised this gist Dec 17, 2020. 1 changed file with 13 additions and 2 deletions.
    15 changes: 13 additions & 2 deletions vue-sanctum.md
    Original file line number Diff line number Diff line change
    @@ -1,11 +1,22 @@
    ## app.yourdomain.test

    vue app created with vue cli.

    package.json
    ```
    {
    - "serve_": "vue-cli-service serve",
    + "serve": "vue-cli-service serve --host app.yourdomain.test --https",
    "serve": "vue-cli-service serve --host app.yourdomain.test --https",
    }
    ```

    ```shell
    yarn serve
    ```

    ## api.yourdomain.test

    Laravel 8 + Laravel sanctum

    ```shell
    cd api.yourdomain
    valet link
  6. royteusink created this gist Dec 17, 2020.
    21 changes: 21 additions & 0 deletions vue-sanctum.md
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,21 @@
    package.json
    ```
    {
    - "serve_": "vue-cli-service serve",
    + "serve": "vue-cli-service serve --host app.yourdomain.test --https",
    }
    ```

    ```shell
    cd api.yourdomain
    valet link
    valet secure
    ```

    .env
    ```ini
    SANCTUM_STATEFUL_DOMAINS="app.yourdomain.test:8080"
    SESSION_DOMAIN=".yourdomain.test"
    SESSION_DRIVER=cookie
    SESSION_LIFETIME=120
    ```