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


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 ...


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

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
List how to learn from Docker to AKS on AWS
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]
Let's write how to make API with SpringBoot + Docker from 0
How to use Chain API
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 switch Java in the OpenJDK era on Mac
How to run React and Rails on the same server
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 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 run a Kotlin Coroutine sample from the command line
[Java] How to convert from String to Path type and get the path
How to use the link_to method
Comments on the COTOHA Parsing API
How to use the include? method
How to use the form_with method
How to deploy Laravel on CentOS 7
[java8] To understand the Stream API
How to "hollow" View on Android
How to find the average angle
How to use the wrapper class
How to use Ruby on Rails
How to deploy Bootstrap on Rails
How to run JavaFX on Docker
How to use Bio-Formats on Ubuntu 20.04
How to install MariaDB 10.4 on CentOS 8
Notes on migrating from CircleCI 1.0 to 2.0
How to install WildFly on Ubuntu 18.04
How to add the delete function
The road from JavaScript to Java
How to change from HTML to Haml
How to narrow down the image format from the gallery on Android and then select and import multiple images
How to place geckodriver (Selenium WebDriver) on the path using Maven command
How to return a value from Model to Controller using the [Swift5] protocol
[Android] How to turn the Notification panel on and off using StatusBarManager
How to run a GIF file from the Linux command line (Ubuntu)
How to solve the problem that notification cannot be requested on iOS14
[Swing] How to display an arbitrary name on the menu bar on Mac
Verify the ID token obtained from Firebase on the server side (Java + SpringBoot)
Get the event that the iOS application moves to the back on the View side
How to convert an array of Strings to an array of objects with the Stream API
[Docker] How to build when the source code is bind-mounted on the container