[RUBY] How to disable Set-Cookie from API on the front side

background

devise-token-auth to create a mobile app version of a Rails web app created using devise When I try to enable token authentication with lynndylanhurley / devise_token_auth), the cookie works and another user information is returned.

What i was doing

I was checking the endpoint created by devise-token-auth by hitting it from the front. If I hit it directly with curl, it would work ...

solution

import { NativeModules } from 'react-native';

NativeModules.Networking.clearCookies(() => { });

The reference article is as it is, but if you do this on the front side (React Native), the cookie sent from the API will be cleared on the front side and it will work as expected.

This time it was supported on the front side, but it seems that it can also be supported by overriding the devise-token-auth controller on the back end side.

Why cookies were stored

It seems that native apps store cookies by default. By the way, although Cookies can not be used by default in Rails API mode, this time I was trying to add token authentication to an existing web application with devise-token-auth, so cookies are being passed. It was.

Reference article

https://qiita.com/kakken1988/items/504e679504b9e710cf21

By the way

We are making an album / photo sharing service called Memopic. Please use it! If you have any opinions or requests, please contact us here ([email protected]).

Not only here, but also when introducing devise-token-auth, I was a little addicted to coexisting with devise, so I will write an article about it soon ~

We look forward to your suggestions and opinions!

Recommended Posts

How to disable Set-Cookie from API on the front side
[Java] How to retrieve the parameters passed from html on the server side
How to display 0 on the left side of the standard input value
SetCookie from the client side with OkHttp3
Migration from Eclipse to IntelliJ (on the way)
[Java] Memo on how to write the source
How to share on the host side (windows) and guest side (CentOS 7) with VirtualBox
How to write Scala from the perspective of Java
[Java] How to extract the file name from the path
[Ruby on Rails] How to change the column name
How to connect to ClearDB from Sequel Pro on Heroku
How to determine the look-ahead request (Prefetch) from the browser
Install MySQL 5.6 on CentOS6 [How to specify the version]
[Ruby On Rails] How to search and save the data of the parent table from the child table
Let's write how to make API with SpringBoot + Docker from 0
How to transition from the [Swift5] app to the iPhone settings screen
How to use Chain API
[IOS] How to get the table name from AWS DynamoDB
How to deploy on heroku
How to create a form to select a date from the calendar
[RuboCop] How to disable warnings
Apache Geode-Easy way to execute logic on the server side
How to get the longest information from Twitter as of 12/12/2016
How to install JDK 8 on Windows without using the installer
[Rails] How to disable turbolinks
How to disable existing selected items in the select box
How to switch Java in the OpenJDK era on Mac
How to run React and Rails on the same server
Learn how to customize the Navigation Bar from the sample app
How to migrate from JUnit4 to JUnit5
How to play MIDI files using the Java Sound API
[Docker] How to access the host from inside the container. http://host.docker.internal:
How to check the database of apps deployed on Heroku
How to apply C code format from the command line
[Swift] How to dynamically change the height of the toolbar on the keyboard
[Rails / Heroku / MySQL] How to reset the DB of Rails application on Heroku
How to install and configure the monitoring tool "Graphite" on Ubuntu
How to display products by category on the same list screen
How to run a Kotlin Coroutine sample from the command line
[Rails] How to put a crown mark on the ranking function
How to place and share SwiftLint config files on the server
[Java] How to convert from String to Path type and get the path
How to use the link_to method
How to deploy jQuery on Rails
Comments on the COTOHA Parsing API
How to use the include? method
How to push from Tarminal to GitHub
How to use the form_with method
How to deploy Laravel on CentOS 7
[java8] To understand the Stream API
How to find the average angle
[Java] How to update Java on Windows
How to install ImageMagick on Windows 10
How to use the wrapper class
How to use Ruby on Rails
How to use Bio-Formats on Ubuntu 20.04
Upgrade from MYSQL5.7 to 8.0 on CentOS 6.7
How to install MariaDB 10.4 on CentOS 8
Rails on Tiles (how to write)
Notes on migrating from CircleCI 1.0 to 2.0
How to install WildFly on Ubuntu 18.04