Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

https://github.com/thegeorgenikhil/go-gin-sveltekit-jwt-cookie-example

An example of how to use JWT authentication with Go Gin and SvelteKit using cookies(*inside SvelteKit*)
https://github.com/thegeorgenikhil/go-gin-sveltekit-jwt-cookie-example

authentication cookie golang sveltekit

Last synced: 14 days ago
JSON representation

An example of how to use JWT authentication with Go Gin and SvelteKit using cookies(*inside SvelteKit*)

Awesome Lists containing this project

README

        

# Go Gin + SvelteKit - JWT Authentication Example using Cookies

An example of how to use JWT authentication with Go Gin and SvelteKit using cookies. The server returns the jwt token in response body and inside SvelteKit we store it in a cookie. The cookie is sent with every request to the server(SvelteKit) when using SSR.

## Setup

### Install dependencies

```bash
# Installing the node dependencies for the frontend
make install_frontend

# Installing the go dependencies for the server
make install_server
```

### Start the server

```bash
make server
```

### Start the client

```bash
make frontend
```

## Routes

| Route | Method | Request Body | Description |
| --------------- | ------ | -------------------- | ----------------------------------------------------------------------------- |
| /auth/login | `POST` | `email` + `password` | Login route, returns a jwt `token` + `message` |
| /auth/signup | `POST` | `email` + `password` | Signup route, returns a jwt `token` + `message` |
| /user/get-my-id | `GET` | `none` | Returns the `id` of the user, needs `Authorization` header with the jwt token |