I am unable to deploy my ember application in Firebase. I can only see the welcome page of Firebase hosting:
You're seeing this because you've successfully setup Firebase Hosting. Now it's time to go build something extraordinary!
I have installed the EmberFire add-on, as well as the Firebase tool.
My config file looks like this:
module.exports = function(environment) {
var ENV = {
modulePrefix: 'sample',
environment: environment,
rootURL: '/',
locationType: 'auto',
firebase : {
apiKey: 'xxxxxx',
authDomain: 'xxxxx',
databaseURL: 'xxxx',
storageBucket: 'xxxxx',
messagingSenderId: 'xxxxx'
},
EmberENV: {
FEATURES: {
// Here you can enable experimental features on an ember canary build
// e.g. 'with-controller': true
}
},
APP: {
// Here you can pass flags/options to your application instance
// when it is created
}
};
if (environment === 'development') {
// ENV.APP.LOG_RESOLVER = true;
ENV.APP.LOG_ACTIVE_GENERATION = true;
ENV.APP.LOG_TRANSITIONS = true;
ENV.APP.LOG_TRANSITIONS_INTERNAL = true;
ENV.APP.
LOG_VIEW_LOOKUPS = true;
}
Firebase.json:
{
"database": {
"rules": "database.rules.json"
},
"hosting": {
"public": "dist",
"rewrites": [
{
"source": "**",
"destination": "/index.html"
}
]
}
}
I have built the app and deployed using following commands:
ember build --prod
firebase login
firebase init
firebase deploy
Thanks in advance :-)
When you initialise your ember.js app with firebase init command for the first time, you will be prompted that
? File dist/index.html already exists. Overwrite? (y/N)
respond with No. Responding with yes will allow the default firebase hosting welcome page override your ember app index.html file, which is why you are still greeted with the firebase hosting welcome page.
Related
NextJs Application is working perfectly fine locally but after pushing the fronted to AWS I'm getting the run time error, No Credentials in callback.js api
No Build time error, so I assume aws-exports.js file is built correctly during the build but I don't know if it is built with the required details like API key on AWS.
I'm using API key authentication by default. I'm not using amplify add auth because I've a requirement to use custom auth. I know amplify auth is the recommend way but I still need to use my custom method.
I have already tried multiple suggestions like disable Analytics: true as suggested in couple of other discussions but none of them worked for me. Build my project multiple times from scratch by re-installing all the dependencies but no luck.
callback.js API
import { API, graphqlOperation } from 'aws-amplify';
import {getAuth} from "../../../../src/graphql/queries"
import {createAuth} from "../../../../src/graphql/mutations"
export default async function callback(req, res) {
const record = await API.graphql(graphqlOperation(getAuth, {emailId: "abc#gmail.com"}))
res.status(200).json({ record });
}
aws-exports.js
/* eslint-disable */
// WARNING: DO NOT EDIT. This file is automatically generated by AWS Amplify. It will be overwritten.
const awsmobile = {
"aws_project_region": "us-east-1",
"aws_appsync_graphqlEndpoint": "https://dummyUrl.appsync-api.us-east-1.amazonaws.com/graphql",
"aws_appsync_region": "us-east-1",
"aws_appsync_authenticationType": "API_KEY",
"aws_appsync_apiKey": "da2-************"
};
export default awsmobile;
_app.js
import {Amplify} from 'aws-amplify';
import config from "../aws-exports"
Amplify.configure(config)
function MyApp({ Component, pageProps: { session, ...pageProps } }) {
// App logic
})
GraphQL Schema
type Auth #model #auth(rules: [{ allow: public }]) {
emailId: ID! #primaryKey
name: String
screen_name: String
profile_img: String
userSession: String
tokenType: String
accessToken: String
accessSecret: String
refreshToken: String
accessScope: String
}
Package.json
"dependencies": {
"#emoji-mart/data": "^1.0.6",
"#emoji-mart/react": "^1.0.1",
"aes256": "^1.1.0",
"aws-amplify": "^4.3.37",
"emoji-mart": "^5.2.2",
"formidable": "^2.0.1",
"js-cookie": "^3.0.1",
"next": "12.3.1",
"react": "18.2.0",
"react-datepicker": "^4.8.0",
"react-dom": "18.2.0",
},
Amplify.yml
version: 1
backend:
phases:
build:
commands:
- '# Execute Amplify CLI with the helper script'
- amplifyPush --simple
frontend:
phases:
preBuild:
commands:
- yarn install
build:
commands:
- yarn run build
artifacts:
baseDirectory: .next
files:
- '**/*'
cache:
paths:
- node_modules/**/*
Edited
I've found how the server side process work with amplify and graphql. Please refer to this. On the server side, you need to pass the API KEY explicitly into the graphql request as that page writes.
==========
I'm using appsync, but appsync pure directives. So just let me provide the reference below. Please confirm the rule follows this way.
{ allow: public, provider: apiKey }
I've written a microservice using NestJS. (Actually two microservices they using the Same Module in one APP structure.)
The North-Bound of microservice is using GRPC and the east-west using RabbitMQ.
North Bound:
const northBound = await NestFactory.createMicroservice<MicroserviceOptions>(
MyModule,
{
transport: Transport.GRPC,
options: {
package: 'mypackage',
protoPath: join(__dirname, 'domain/myservice.proto'),
url: `0.0.0.0:${MY_GRPC_PORT}`,
loader: { keepCase: true, defaults: true },
},
logger: northBoundLogger,
},
);
East-West:
const eastwest = await NestFactory.createMicroservice<MicroserviceOptions>(
MyModule,
{
transport: Transport.RMQ,
options: {
urls: [`amqp://${RABBITMQ_USER}:${RABBITMQ_PASSWORD}#${RABBITMQ_HOST}`],
queue: RABBITMQ_MY_QUEUE,
queueOptions: {
durable: true,
},
noAck: true,
},
logger: eastwestLogger,
},
);
I can't find out any example on the web which has deployed a non-HTTP nestjs micro-service using serverless framework on AWS lambda.
Is this possible?
I just finished my project in Strapi and deployed in AWS, when I run my Public ipv4 :1337 says: 'server is running successully' but when I want to log in admin panel just spinning and not showing panel.
server.js
module.exports = ({ env }) => ({
host: env('HOST', '0.0.0.0'),
port: env.int('PORT', 1337),
cron: { enabled: true},
url: env('URL', 'http://localhost'),
admin: {
auth: {
secret: env('ADMIN_JWT_SECRET', 'MY_JWT_SECRET'),
},
},
});
I want to set token to cookies after user logged in on the website.
I found this apollo-server-plugin-http-headers package.
So I'm trying to do this in my resolver.
async loginUser(_, { loginInput }, context) {
...
const token = generateToken(user);
context.setCookies.push({
name: "cookieName",
value: token,
options: {
httpOnly: true,
maxAge: 3600,
path: "/",
sameSite: true,
secure: true
}
});
console.log(context, 123)
return {
...
token
}
In setting up apollo server in
const httpHeadersPlugin = require("apollo-server-plugin-http-headers");
const server = new ApolloServer({
typeDefs,
resolvers,
plugins: [httpHeadersPlugin],
context: {
setHeaders: new Array(),
setCookies: new Array(),
}
});
I'm checking browsers cookies tab, in Chrome application -> cookies, but nothing is set there. I'm not sure what am I doing wrong? Maybe there is another way to do it?
All the help will be much appreciated
You cannot set the cookie option secure for localhost, i.e. in development mode. Try setting secure: process.env.NODE_ENV === 'production'
That is:
context.setCookies.push({
name: "cookieName",
value: token,
options: {
httpOnly: true,
maxAge: 3600,
path: "/",
sameSite: true,
secure: process.env.NODE_ENV === 'production'
}
});
Trying to do cookies with schema stitching was a bear for me to figure out. For a deeper dive you can check out this repo which uses the apollo-server-plugin-http-headers plugin.
I keep receiving the error that the session var is not defined. I've looked at other answers on here about restarting ember serve to remove any caching issues but I've tried that multiple times and I've followed the emberfire guide to the letter. Does anyone have any idea what could be going wrong? The authentication succeeds but the session doesn't get bound to. Here are my files:
/app/routes/application.js
import Ember from 'ember';
export default Ember.Route.extend({
model: function() {
return this.store.query('post', {
orderBy: 'timestamp',
limitToLast: 3
});
},
actions: {
authenticate: function(username, pass) {
this.get('session').open('firebase', {
provider: "password",
email: username,
password: pass
}).then(function (data) {
console.log(data.currentUser);
console.log(session);
});
}
}
});
/app/torii-adapters
import Ember from 'ember';
import ToriiFirebaseAdapter from 'emberfire/torii-adapters/firebase';
export default ToriiFirebaseAdapter.extend({
firebase: Ember.inject.service()
});
/config/environment.js
var ENV = {
modulePrefix: 'website',
environment: environment,
contentSecurityPolicy: { 'connect-src': "'self' https://auth.firebase.com wss://*.firebaseio.com" },
firebase: 'https://REMOVED.firebaseio.com/',
torii: {
sessionServiceName: 'session'
},
baseURL: '/',
locationType: 'auto',
EmberENV: {
FEATURES: {
// Here you can enable experimental features on an ember canary build
// e.g. 'with-controller': true
}
},
APP: {
// Here you can pass flags/options to your application instance
// when it is created
}
};
I was having the same issue following the tutorial for emberfire. I solved the issue by explicitly install torii via npm:
npm install torii
Restarted the server and all is well.